Skip to content
This repository was archived by the owner on May 16, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ def run_migrations_online():
run_migrations_offline()
else:
run_migrations_online()

22 changes: 22 additions & 0 deletions alembic/versions/29c2cf7cd05f_add_comments_to_even.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Add comments to events

Revision ID: 29c2cf7cd05f
Revises: 2e8783dd05
Create Date: 2013-04-19 21:29:32.485229

"""

# revision identifiers, used by Alembic.
revision = '29c2cf7cd05f'
down_revision = '2e8783dd05'

from alembic import op
import sqlalchemy as sa


def upgrade():
op.add_column('event', sa.Column('comments_id', sa.Integer, sa.ForeigenKey('commentspace.id')))


def downgrade():
op.remove_column('event', 'comments_id')
4 changes: 3 additions & 1 deletion hacknight/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

db = SQLAlchemy(app)

from hacknight.models.user import *
from hacknight.models.event import *
from hacknight.models.user import *
from hacknight.models.profile import *
from hacknight.models.venue import *
from hacknight.models.project import *
from hacknight.models.participant import *
from hacknight.models.sponsor import *
from hacknight.models.comment import *
6 changes: 2 additions & 4 deletions hacknight/models/comment.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8- *-

from hacknight.models import BaseMixin, BaseScopedIdNameMixin, BaseScopedIdMixin
from hacknight.models import BaseMixin, BaseScopedIdMixin
from hacknight.models import db
from hacknight.models.event import Event
from hacknight.models.participant import Participant
from hacknight.models.user import User
from hacknight.models.vote import Vote, VoteSpace
from hacknight.models.vote import VoteSpace

__all__ = ['CommentSpace', 'Comment']

Expand Down
22 changes: 22 additions & 0 deletions hacknight/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
from flask import url_for
from flask.ext.lastuser.sqlalchemy import ProfileMixin
from sqlalchemy.orm import deferred
<<<<<<< HEAD
from hacknight.models import db, BaseScopedNameMixin
from hacknight.models.profile import Profile
from hacknight.models.comment import CommentSpace


__all__ = ['Event', 'EVENT_STATUS']
=======
from hacknight.models import db, BaseNameMixin, BaseScopedNameMixin, BaseMixin

__all__ = ['Profile', 'Event', 'EVENT_STATUS', 'PROFILE_TYPE', 'EventRedirect']
>>>>>>> master
#need to add EventTurnOut, EventPayment later


Expand Down Expand Up @@ -34,6 +43,8 @@ class EVENT_STATUS:
WITHDRAWN = 7


<<<<<<< HEAD
=======
class Profile(ProfileMixin, BaseNameMixin, db.Model):
__tablename__ = 'profile'

Expand All @@ -51,8 +62,10 @@ def url_for(self, action='view', _external=True):
return url_for('event_new', profile=self.name, _external=_external)


>>>>>>> master
class Event(BaseScopedNameMixin, db.Model):
__tablename__ = 'event'

profile_id = db.Column(db.Integer, db.ForeignKey('profile.id'), nullable=False)
profile = db.relationship(Profile)
parent = db.synonym('profile')
Expand All @@ -76,8 +89,17 @@ class Event(BaseScopedNameMixin, db.Model):
pending_message = deferred(db.Column(db.UnicodeText, nullable=False, default=u''))
pending_message_text = deferred(db.Column(db.UnicodeText, nullable=False, default=u''))

#event wall
comments_id = db.Column(db.Integer, db.ForeignKey('commentspace.id'), nullable=False)
comments = db.relationship(CommentSpace, uselist=False)

__table_args__ = (db.UniqueConstraint('name', 'profile_id'),)

def __init__(self, **kwargs):
super(Event, self).__init__(**kwargs)
if not self.comments:
self.comments = CommentSpace()

def owner_is(self, user):
"""Check if a user is an owner of this event"""
return user is not None and self.profile.userid in user.user_organizations_owned_ids()
Expand Down
37 changes: 37 additions & 0 deletions hacknight/models/profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-

from flask import url_for
from hacknight.models import db, BaseNameMixin

__all__ = ['Profile', 'PROFILE_TYPE']


class PROFILE_TYPE:
UNDEFINED = 0
PERSON = 1
ORGANIZATION = 2
EVENTSERIES = 3

profile_types = {
0: u"Undefined",
1: u"Person",
2: u"Organization",
3: u"Event Series",
}


class Profile(BaseNameMixin, db.Model):
__tablename__ = 'profile'

userid = db.Column(db.Unicode(22), nullable=False, unique=True)
description = db.Column(db.UnicodeText, default=u'', nullable=False)
type = db.Column(db.Integer, default=PROFILE_TYPE.UNDEFINED, nullable=False)

def type_label(self):
return profile_types.get(self.type, profile_types[0])

def url_for(self, action='view', _external=True):
if action == 'view':
return url_for('profile_view', profile=self.name, _external=_external)
elif action == 'new-event':
return url_for('event_new', profile=self.name, _external=_external)
2 changes: 1 addition & 1 deletion hacknight/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flask import url_for
from flask.ext.lastuser.sqlalchemy import UserBase
from hacknight.models import db
from hacknight.models.event import Profile
from hacknight.models.profile import Profile

__all__ = ['User']

Expand Down
2 changes: 1 addition & 1 deletion hacknight/models/venue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flask import url_for
from hacknight.models import BaseNameMixin
from hacknight.models import db
from hacknight.models.event import Profile
from hacknight.models.profile import Profile

__all__ = ['Venue']

Expand Down
6 changes: 3 additions & 3 deletions hacknight/models/vote.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8- *-

from hacknight.models import BaseMixin, BaseScopedIdNameMixin
from hacknight.models import BaseMixin
from hacknight.models import db
from hacknight.models.event import Event
from hacknight.models.participant import Participant
from hacknight.models.user import User


__all__ = ['VoteSpace', 'Vote']


class VoteSpace(BaseMixin, db.Model):
__tablename__ = 'votespace'
type = db.Column(db.Integer, nullable=True)
Expand Down
2 changes: 1 addition & 1 deletion hacknight/templates/comment_owner_email.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**{{ g.user.username }}** replied to you in the project **{{ project.title }}**
**{{ g.user.username }}** replied to you {% if wall %} on the event wall {% else %} in the project {% endif %} **{{ project.title }}**

{{ comment.message }}

Expand Down
56 changes: 55 additions & 1 deletion hacknight/templates/event.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{% extends "layout.html" %}
{% from "comments.html" import commenttree %}
{% from "forms.html" import renderform, ajaxform %}

{% block title %}{{ event.title }}{% endblock %}

{% macro participant_list(event, participants) -%}
Expand Down Expand Up @@ -142,6 +145,7 @@ <h4 class="nav-header">Sponsors</h4>
<ul class="nav nav-tabs nav-tabs-auto">
<li><a href="#participants" data-toggle="tab">Participants</a></li>
<li><a href="#projects" data-toggle="tab">Projects</a></li>
<li><a href="#wall" data-toggle="tab">Event Wall</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="participants">
Expand Down Expand Up @@ -192,6 +196,55 @@ <h2>New project...</h2>
</ul>
</div>
</div>
<div class="tab-pane" id="wall">
<div class="row">
<div class="span9">
<div class="section"> <b> Discussion space for Hacknight </b>
<h3 class="h3-title" id="comments">Comments</h3>
{% if comments %}
<ul class="comments">
{{ commenttree(comments, event, g.user, request.base_url) }}
</ul>
{% endif %}
{% if not g.user -%}
<p>
<a href="{{ url_for('login') }}">Login with Twitter or Google to leave a comment &rarr;</a>
</p>
{% else -%}
<p id="toplevel-comment" class="hidden">
<a href="#">Post a comment &rarr;</a>
</p>
<form method="POST" id="newcomment">
<div class="hidden">
<input type="hidden" name="form.id" value="newcomment"/>
{{ commentform.hidden_tag() }}
{{ commentform.reply_to_id() }}
{{ commentform.edit_id() }}
</div>
<p>
{{ commentform.message() }}
</p>
<p>
<input id="comment-submit" type="submit" value="Post comment"/>
</p>
</form>
<form method="POST" id="delcomment" class="hidden">
<div class="hidden">
<input type="hidden" name="form.id" value="delcomment"/>
{{ delcommentform.hidden_tag() }}
{{ delcommentform.comment_id() }}
</div>
<p>
Really delete this comment?
<input id="comment-delete-submit" type="submit" value="Delete"/>
or <a id="comment-delete-cancel" href="#">cancel</a>
</p>
</form>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% if event.venue.latitude and event.venue.longitude %}
<div class="box-border"><div id="map" class="event-map"></div></div>
Expand Down Expand Up @@ -235,7 +288,8 @@ <h2>New project...</h2>
function onZoomend(){
map.setView(venue, map.getZoom());
};
{% endif %}
{% endif %}
commentsInit("{{ request.base_url }}");
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion hacknight/templates/project_owner_email.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**{{ g.user.username }}** left a comment on your project **{{ project.title }}**
**{{ g.user.username }}** left a comment {% if wall %} on the event wall {% else %} on your project {% endif %} **{{ project.title }}**

{{ comment.message }}

Expand Down
2 changes: 1 addition & 1 deletion hacknight/templates/project_team_email.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**{{ g.user.username }}** left a comment in the project **{{ project.title }}**
**{{ g.user.username }}** left a comment {% if wall %} on the event wall {% else %} in the project {% endif %} **{{ project.title }}**

{{ comment.message }}

Expand Down
Loading