community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r1692831 - in /comdev/tools/events_list: models.py templates/events/index.html views.py
Date Mon, 27 Jul 2015 08:13:01 GMT
Author: rgardler
Date: Mon Jul 27 08:13:01 2015
New Revision: 1692831

URL: http://svn.apache.org/r1692831
Log:
Allow searching on multiple hashtags. Remove 'Meetup' as a hashtag

Modified:
    comdev/tools/events_list/models.py
    comdev/tools/events_list/templates/events/index.html
    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=1692831&r1=1692830&r2=1692831&view=diff
==============================================================================
--- comdev/tools/events_list/models.py (original)
+++ comdev/tools/events_list/models.py Mon Jul 27 08:13:01 2015
@@ -42,6 +42,7 @@ class Event(models.Model):
         hashtags = self.hashtags.all()
         for hashtag in hashtags:
             tweet = tweet + " #" + hashtag.name
+        tweet = tweet + " #Meetup"
         return tweet
 
     @property

Modified: comdev/tools/events_list/templates/events/index.html
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/templates/events/index.html?rev=1692831&r1=1692830&r2=1692831&view=diff
==============================================================================
--- comdev/tools/events_list/templates/events/index.html (original)
+++ comdev/tools/events_list/templates/events/index.html Mon Jul 27 08:13:01 2015
@@ -24,6 +24,7 @@
       <th>Name</th>
       <th>City</th>
       <th>Country</th>
+      <th>Hashtags</th>
       <th>Local Start Time</th>
       <th>Applicable</th>
       <th>Social</th>
@@ -35,6 +36,11 @@
       <td><a href="{{ event.event_url }}" target="_blank">{{ event.name }}</a></td>
       <td>{{ event.group.city }}, {{ event.group.state }}</td>
       <td>{{ event.group.country }}</td>
+      <td>
+	{% for hashtag in event.hashtags.all %}
+	  {{ hashtag.name }}<br/>
+	{% endfor %}
+      </td>
       <td data-order='{{ event.date_sort }}'>{{ event.local_start }}</td>
       <td><a href="{% url 'toggleNA' event.id %}">Mark N/A</a></td>
       <td>
@@ -58,7 +64,7 @@
 <script>
   $(document).ready(function(){
     $('#eventList').dataTable({
-       "order": [[ 3, "asc" ]],
+       "order": [[ 4, "asc" ]],
        "stateSave": true
     });
   });

Modified: comdev/tools/events_list/views.py
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/views.py?rev=1692831&r1=1692830&r2=1692831&view=diff
==============================================================================
--- comdev/tools/events_list/views.py (original)
+++ comdev/tools/events_list/views.py Mon Jul 27 08:13:01 2015
@@ -54,35 +54,30 @@ def importMeetups(request):
     log.action_type = Log.EVENT_IMPORT
     log.save()
 
-    # 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 ..."
+
+    # get all the hashtags from the DB
+    hashtags = Hashtag.objects.all().exclude(name = "Meetup")
+
+    # iterate over them all makeing a call to meetups.com for each one and adding results
to the database
+    for hashtag in hashtags:
+      _callMeetupsCom(hashtag)
+
+    template = loader.get_template('events/importMeetups.html')
+    context = RequestContext(request)
+    return HttpResponse(template.render(context))
+
+def _callMeetupsCom(hashtag):
+    print "searching meetups.com for " + hashtag.name
 
     # Note that this API key is *my* API key (rbowen) and if we start using
     # it more than a few dozen times an hour it's likely to get revoked.
     # Please play nice.
+    # FIXME: make this a configuration value
     key = "3a7711454d145e404e531c2ee6f391d"
 
     # 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_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_hashtag.name + "&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="
+ hashtag.name + "&radius=10000&sign=true&key=" + key
 
     print "Fetching meetups ..."
 
@@ -157,14 +152,9 @@ def importMeetups(request):
             event.utc_offset = offset
             event.save()
 
-            event.hashtags.add(apache_hashtag)
-            event.hashtags.add(meetup_hashtag)
+            event.hashtags.add(hashtag)
             event.save()
         except:
             print('Unable to save Event object: '), sys.exc_info()[0], sys.exc_info()[1]
-
-    template = loader.get_template('events/importMeetups.html')
-    context = RequestContext(request)
-    return HttpResponse(template.render(context))
     
 



Mime
View raw message