community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r1684096 - in /comdev/tools: comdev_tools/settings.py events_list/models.py events_list/templates/events/index.html events_list/views.py
Date Mon, 08 Jun 2015 05:53:17 GMT
Author: rgardler
Date: Mon Jun  8 05:53:17 2015
New Revision: 1684096

URL: http://svn.apache.org/r1684096
Log:
turn off timexone support since meetup.com works only in UTC

Modified:
    comdev/tools/comdev_tools/settings.py
    comdev/tools/events_list/models.py
    comdev/tools/events_list/templates/events/index.html
    comdev/tools/events_list/views.py

Modified: comdev/tools/comdev_tools/settings.py
URL: http://svn.apache.org/viewvc/comdev/tools/comdev_tools/settings.py?rev=1684096&r1=1684095&r2=1684096&view=diff
==============================================================================
--- comdev/tools/comdev_tools/settings.py (original)
+++ comdev/tools/comdev_tools/settings.py Mon Jun  8 05:53:17 2015
@@ -97,7 +97,7 @@ USE_I18N = True
 
 USE_L10N = True
 
-USE_TZ = True
+USE_TZ = False
 
 
 # Static files (CSS, JavaScript, Images)

Modified: comdev/tools/events_list/models.py
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/models.py?rev=1684096&r1=1684095&r2=1684096&view=diff
==============================================================================
--- comdev/tools/events_list/models.py (original)
+++ comdev/tools/events_list/models.py Mon Jun  8 05:53:17 2015
@@ -10,12 +10,22 @@ class Group(models.Model):
     def __str__(self):
         return self.name
 
+    def __unicode__(self):
+        return u'{n}, {c}, {s}, {co}'.format(n=self.name, c=self.city, s=self.state, co=self.country)
+
     
 class Event(models.Model):
     name = models.CharField(max_length=200)
     event_url = models.URLField()
     group = models.ForeignKey(Group)
     meetupID = models.CharField(verbose_name = "Meetups.com ID", max_length=50, unique=True)
-
+    description = models.TextField()
+    local_start = models.DateTimeField()
+    local_end = models.DateTimeField()
+    utc_offset = models.BigIntegerField()
+    
     def __str__(self):
-        return self.name
+        return u'{n}, {d}'.format(n=self.name, d=self.utc_start)
+
+    def __unicode__(self):
+        return u'{n}, {d}'.format(n=self.name, d=self.utc_start)

Modified: comdev/tools/events_list/templates/events/index.html
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/templates/events/index.html?rev=1684096&r1=1684095&r2=1684096&view=diff
==============================================================================
--- comdev/tools/events_list/templates/events/index.html (original)
+++ comdev/tools/events_list/templates/events/index.html Mon Jun  8 05:53:17 2015
@@ -1,2 +1,21 @@
 <h1>Events</h1>
+{% if upcoming_events_list %}
+<table>
+  <tr>
+    <th>Name</th>
+    <th>Local Start Time</th>
+    <th>Local End Time</th>
+  </tr>
+  {% for event in upcoming_events_list %}
+  <tr>
+    <td><a href="{{ event.event_url }}">{{ event.name }}</a></td>
+    <td>{{ event.local_start }}</td>
+    <td>{{ event.local_end }}</td>
+  </tr>
+  {% endfor %}
+</table>	
+{% else %}
+<p>No events are available.</p>
+{% endif %}
+  
 <a href="/events/importMeetups">Import Meetups</a>

Modified: comdev/tools/events_list/views.py
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/views.py?rev=1684096&r1=1684095&r2=1684096&view=diff
==============================================================================
--- comdev/tools/events_list/views.py (original)
+++ comdev/tools/events_list/views.py Mon Jun  8 05:53:17 2015
@@ -2,6 +2,7 @@ from django.shortcuts import get_object_
 from django.http import HttpResponse
 from django.template import RequestContext, loader
 from events_list.models import Event, Group
+from datetime import datetime, timedelta
 import json
 import logging
 import urllib2
@@ -10,8 +11,12 @@ import sys
 logger = logging.getLogger(__name__)
 
 def index(request):
+    now = datetime.now()
+    upcoming_events_list = Event.objects.filter(local_start__gte=now).order_by('local_start')[:20]
     template = loader.get_template('events/index.html')
-    context = RequestContext(request)
+    context = RequestContext(request, {
+                             'upcoming_events_list': upcoming_events_list,
+    })
     return HttpResponse(template.render(context))
 
 def importMeetups(request):
@@ -72,14 +77,14 @@ def importMeetups(request):
         
         try:
             group.meetupID = grp['id']
-            group.name = grp['name']
-            group.city = grp['city']
+            group.name = unicode(grp['name'])
+            group.city = unicode(grp['city'])
             if 'state' in grp.keys():
                 group.state = grp['state']
             group.country = grp['country']
             group.save()
         except:
-            print('Unable to save Group object: '), sys.exc_info()[0]
+            print('Unable to save Group object: '), sys.exc_info()[0], sys.exc_info()[1]
 
         try:
             event = Event.objects.get(meetupID = meetup['id'])
@@ -87,13 +92,23 @@ def importMeetups(request):
             event = Event()
 
         try:
-            event.name = meetup['name']
+            event.name = unicode(meetup['name'])
             event.event_url = meetup['event_url']
             event.meetupID = meetup['id']
             event.group = group
+            event.description = unicode(meetup['description'])
+            start = float(str(meetup['time'])[0:-3])
+            if 'duration' in meetup.keys():
+                end = float(str(meetup['duration'])[0:-3])
+            else:
+                end = 0
+            offset = float(str(meetup['utc_offset'])[0:-3])
+            event.local_start = datetime.utcfromtimestamp(start + offset)
+            event.local_end = datetime.utcfromtimestamp(start + end + offset)
+            event.utc_offset = offset
             event.save()
         except:
-            print('Unable to save Event object: '), sys.exc_info()[0]
+            print('Unable to save Event object: '), sys.exc_info()[0], sys.exc_info()[1]
 
     template = loader.get_template('events/importMeetups.html')
     context = RequestContext(request)



Mime
View raw message