community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r1692692 - in /comdev/tools/events_list: Dockerfile models.py views.py
Date Sun, 26 Jul 2015 06:50:31 GMT
Author: rgardler
Date: Sun Jul 26 06:50:30 2015
New Revision: 1692692

URL: http://svn.apache.org/r1692692
Log:
Don't need the Dockerfile in the app directory

Removed:
    comdev/tools/events_list/Dockerfile
Modified:
    comdev/tools/events_list/models.py
    comdev/tools/events_list/views.py

Modified: comdev/tools/events_list/models.py
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/models.py?rev=1692692&r1=1692691&r2=1692692&view=diff
==============================================================================
--- comdev/tools/events_list/models.py (original)
+++ comdev/tools/events_list/models.py Sun Jul 26 06:50:30 2015
@@ -14,13 +14,13 @@ class Group(models.Model):
         return u'{n}, {c}, {s}, {co}'.format(n=self.name, c=self.city, s=self.state, co=self.country)
 
 class Hashtag(models.Model):
-    hashtag = models.CharField(max_length=15)
+    name = models.CharField(max_length=15)
 
     def __str__(self):
-        return self.hashtag
+        return self.name
 
     def __unicode__(self):
-        return unicode(self.hashtag)
+        return unicode(self.name)
 
     
 class Event(models.Model):
@@ -32,15 +32,15 @@ class Event(models.Model):
     local_start = models.DateTimeField()
     local_end = models.DateTimeField()
     utc_offset = models.BigIntegerField()
-    hashtag = models.ManyToManyField(Hashtag)
+    hashtags = models.ManyToManyField(Hashtag, related_name="events")
     is_applicable = models.BooleanField(help_text = "Indicates if an event is applicable
to our audience or not.", default=True)
     
     @property
     def tweet(self):
         tweet = self.group.city + ", " + self.local_start.strftime("%-d %b") + ": " + self.name
-        hashtags = self.hashtag.all()
+        hashtags = self.hashtags.all()
         for hashtag in hashtags:
-            tweet = tweet + " #" + hashtag.hashtag
+            tweet = tweet + " #" + hashtag.name
         return tweet
     
     def __str__(self):

Modified: comdev/tools/events_list/views.py
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/views.py?rev=1692692&r1=1692691&r2=1692692&view=diff
==============================================================================
--- comdev/tools/events_list/views.py (original)
+++ comdev/tools/events_list/views.py Sun Jul 26 06:50:30 2015
@@ -29,6 +29,21 @@ def toggleNA(request, event_id):
     
 def importMeetups(request):
     # Import latest meetups from meetup.com
+
+    # FIXME: make these fixtures when installing app
+    try:
+        apache_hashtag = Hashtag.objects.get(name = 'Apache')
+    except Hashtag.DoesNotExist:
+        apache_hashtag = Hashtag()
+        apache_hashtag.name = 'Apache'
+        apache_hashtag.save()
+
+    try:
+        meetup_hashtag = Hashtag.objects.get(name = 'Meetup')
+    except Hashtag.DoesNotExist:
+        meetup_hashtag = Hashtag()
+        meetup_hashtag.name = 'Meetup'
+        meetup_hashtag.save()
     
     print "Rounding up the ponies ..."
 
@@ -39,11 +54,11 @@ def importMeetups(request):
 
     # Radius is defined around Lexington, KY, but it's infinite radius, so
     # should work everywhere.
-    url = "https://api.meetup.com/2/open_events?&sign=true&photo-host=public&state=ky&city=lexington&country=usa&text=apache&radius=10000&sign=true&key="
+ key
+    url = "https://api.meetup.com/2/open_events?&sign=true&photo-host=public&state=ky&city=lexington&country=usa&text="
+ apache_hashtag.name + "&radius=10000&sign=true&key=" + key
 
     # Radius is defined around Lexington, KY, but it's infinite radius, so
     # should work everywhere.
-    url = "https://api.meetup.com/2/open_events?&sign=true&photo-host=public&state=ky&city=lexington&country=usa&text=apache&radius=10000&sign=true&key="
+ key
+    url = "https://api.meetup.com/2/open_events?&sign=true&photo-host=public&state=ky&city=lexington&country=usa&text="
+ apache_hashtag.name + "&radius=10000&sign=true&key=" + key
 
     print "Fetching meetups ..."
 
@@ -76,21 +91,6 @@ def importMeetups(request):
     for g in grps:
         grp_deets[ g['id'] ] = g
 
-    # FIXME: make these fixtures when installing app
-    try:
-        apache_hashtag = Hashtag.objects.get(hashtag = 'Apache')
-    except Hashtag.DoesNotExist:
-        apache_hashtag = Hashtag()
-        apache_hashtag.hashtag = 'Apache'
-        apache_hashtag.save()
-
-    try:
-        meetup_hashtag = Hashtag.objects.get(hashtag = 'Meetup')
-    except Hashtag.DoesNotExist:
-        meetup_hashtag = Hashtag()
-        meetup_hashtag.hashtag = 'Meetup'
-        meetup_hashtag.save()
-        
     for meetup in meetups:
         # Group information ...
         grp = grp_deets[ meetup['group']['id'] ]
@@ -131,8 +131,10 @@ def importMeetups(request):
             event.local_start = datetime.utcfromtimestamp(start + offset)
             event.local_end = datetime.utcfromtimestamp(start + end + offset)
             event.utc_offset = offset
-            event.hashtag.add(apache_hashtag)
-            event.hashtag.add(meetup_hashtag)
+            event.save()
+
+            event.hashtags.add(apache_hashtag)
+            event.hashtags.add(meetup_hashtag)
             event.save()
         except:
             print('Unable to save Event object: '), sys.exc_info()[0], sys.exc_info()[1]



Mime
View raw message