Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON for topics #24

Merged
merged 4 commits into from
Apr 14, 2012
Merged
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: 1 addition & 0 deletions meetings/migrations/001.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "meetings_topic" ADD COLUMN start_time datetime null;
3 changes: 2 additions & 1 deletion meetings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __unicode__(self):
stamp_modified = models.DateTimeField(auto_now=True)

def is_future(self):
return bool( self.when >= ( datetime.datetime.now()-settings.LATE_ARRIVAL_OFFSET ) )
return bool( self.when >= ( datetime.datetime.now()-settings.LATE_ARRIVAL_OFFSET ) )


def rsvp_user_yes(self):
Expand Down Expand Up @@ -101,6 +101,7 @@ def __unicode__(self):
embed_video = models.TextField(blank=True,null=True)
description = models.TextField(blank=True,null=True)
slides_link = models.URLField(verify_exists=True, blank=True, null=True)
start_time = models.DateTimeField(blank = True, null = True)

stamp_created = models.DateTimeField(auto_now_add=True)
stamp_modified = models.DateTimeField(auto_now=True)
Expand Down
1 change: 1 addition & 0 deletions meetings/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
url(r'^embed_video/(?P<id>\d+)/$', embed_video, {},'embed_video'),
(r'^rsvp_update$', 'meetings.views.rsvp_update'),
(r'^rsvp/(?P<mid>\d+)/(?P<msg>.+)$', 'meetings.views.rsvp'),
url(r'(?P<meeting>\d+)/topics.json', topics_json, name="topics.json"),
)
15 changes: 15 additions & 0 deletions meetings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from meetings.models import MeetingRsvp, Meeting
from datetime import *
from django.contrib import messages
import simplejson

def embed_video(request,id):
topic = get_object_or_404(Topic, pk=id)
Expand Down Expand Up @@ -70,4 +71,18 @@ def rsvp_update(request):

return HttpResponse(str(ok))

def topics_json(request, meeting):
meeting = get_object_or_404(Meeting, pk=meeting)
topics = []
for topic in meeting.topic_set.all():
topics.append({'title' : topic.title,
'presenter' : topic.by.name if topic.by else '',
'contact_email' : topic.by.email if topic.by else '',
'start_time' : topic.start_time.isoformat() if topic.start_time else '',
'duration' : topic.length,
'description': topic.description,
'released' : True,
})

return HttpResponse(simplejson.dumps(topics), mimetype="application/json")