From a8a20f273a6799ea180251c8680603bf5f5ba2e1 Mon Sep 17 00:00:00 2001 From: Cezar Date: Sat, 7 Apr 2012 23:30:50 -0500 Subject: [PATCH 1/4] Adding json output for topics --- meetings/models.py | 2 +- meetings/urls.py | 1 + meetings/views.py | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/meetings/models.py b/meetings/models.py index 7fe7333..47fc11a 100755 --- a/meetings/models.py +++ b/meetings/models.py @@ -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): diff --git a/meetings/urls.py b/meetings/urls.py index 736d2e5..e1fd46b 100644 --- a/meetings/urls.py +++ b/meetings/urls.py @@ -7,4 +7,5 @@ url(r'^embed_video/(?P\d+)/$', embed_video, {},'embed_video'), (r'^rsvp_update$', 'meetings.views.rsvp_update'), (r'^rsvp/(?P\d+)/(?P.+)$', 'meetings.views.rsvp'), + url(r'(?P\d+)/topics.json', topics_json, name="topics.json"), ) diff --git a/meetings/views.py b/meetings/views.py index eabd0c9..fa192e3 100644 --- a/meetings/views.py +++ b/meetings/views.py @@ -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) @@ -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, + 'contact_email' : topic.by.email, + 'start_time' : '00:00:00', + 'duration' : topic.length, + 'description': topic.description, + 'released' : True, + }) + + return HttpResponse(simplejson.dumps(topics), mimetype="application/json") From 35b7758352c60054725537c314412f24b18bdace Mon Sep 17 00:00:00 2001 From: Cezar Date: Sun, 8 Apr 2012 15:26:18 -0500 Subject: [PATCH 2/4] Outing isoformat --- meetings/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meetings/views.py b/meetings/views.py index fa192e3..66e953a 100644 --- a/meetings/views.py +++ b/meetings/views.py @@ -78,7 +78,7 @@ def topics_json(request, meeting): topics.append({'title' : topic.title, 'presenter' : topic.by.name, 'contact_email' : topic.by.email, - 'start_time' : '00:00:00', + 'start_time' : meeting.when.isoformat(), 'duration' : topic.length, 'description': topic.description, 'released' : True, From 11760830b936ba32728ba96edf49177e246c7e8b Mon Sep 17 00:00:00 2001 From: Cezar Jenkins Date: Mon, 9 Apr 2012 09:00:18 -0500 Subject: [PATCH 3/4] Added start time for topics --- meetings/migrations/001.sql | 1 + meetings/models.py | 1 + 2 files changed, 2 insertions(+) create mode 100644 meetings/migrations/001.sql diff --git a/meetings/migrations/001.sql b/meetings/migrations/001.sql new file mode 100644 index 0000000..3ac4289 --- /dev/null +++ b/meetings/migrations/001.sql @@ -0,0 +1 @@ +ALTER TABLE "meetings_topic" ADD COLUMN start_time datetime null; diff --git a/meetings/models.py b/meetings/models.py index 47fc11a..0052b1c 100755 --- a/meetings/models.py +++ b/meetings/models.py @@ -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) From a287e2b66f010f439ab556a7ccec132352f8f7bf Mon Sep 17 00:00:00 2001 From: Cezar Jenkins Date: Mon, 9 Apr 2012 09:14:38 -0500 Subject: [PATCH 4/4] Added start time sql and in JSON generation --- meetings/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meetings/views.py b/meetings/views.py index 66e953a..36fc43f 100644 --- a/meetings/views.py +++ b/meetings/views.py @@ -76,9 +76,9 @@ def topics_json(request, meeting): topics = [] for topic in meeting.topic_set.all(): topics.append({'title' : topic.title, - 'presenter' : topic.by.name, - 'contact_email' : topic.by.email, - 'start_time' : meeting.when.isoformat(), + '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,