community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r1684098 - in /comdev/tools/events_list: models.py templates/events/index.html urls.py views.py
Date Mon, 08 Jun 2015 06:30:54 GMT
Author: rgardler
Date: Mon Jun  8 06:30:54 2015
New Revision: 1684098

URL: http://svn.apache.org/r1684098
Log:
allow events to be marked as not applicable and thus filter them from view

Modified:
    comdev/tools/events_list/models.py
    comdev/tools/events_list/templates/events/index.html
    comdev/tools/events_list/urls.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=1684098&r1=1684097&r2=1684098&view=diff
==============================================================================
--- comdev/tools/events_list/models.py (original)
+++ comdev/tools/events_list/models.py Mon Jun  8 06:30:54 2015
@@ -23,9 +23,10 @@ class Event(models.Model):
     local_start = models.DateTimeField()
     local_end = models.DateTimeField()
     utc_offset = models.BigIntegerField()
+    is_applicable = models.BooleanField(help_text = "Indicates if an event is applicable
to our audience or not.", default=True)
     
     def __str__(self):
-        return u'{n}, {d}'.format(n=self.name, d=self.utc_start)
+        return u'{n}, {d}'.format(n=self.name, d=self.local_start)
 
     def __unicode__(self):
-        return u'{n}, {d}'.format(n=self.name, d=self.utc_start)
+        return u'{n}, {d}'.format(n=self.name, d=self.local_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=1684098&r1=1684097&r2=1684098&view=diff
==============================================================================
--- comdev/tools/events_list/templates/events/index.html (original)
+++ comdev/tools/events_list/templates/events/index.html Mon Jun  8 06:30:54 2015
@@ -11,6 +11,7 @@
     <td><a href="{{ event.event_url }}">{{ event.name }}</a></td>
     <td>{{ event.local_start }}</td>
     <td>{{ event.local_end }}</td>
+    <td><a href="{% url 'toggleNA' event.id %}">Mark N/A</a></td>
   </tr>
   {% endfor %}
 </table>	

Modified: comdev/tools/events_list/urls.py
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/urls.py?rev=1684098&r1=1684097&r2=1684098&view=diff
==============================================================================
--- comdev/tools/events_list/urls.py (original)
+++ comdev/tools/events_list/urls.py Mon Jun  8 06:30:54 2015
@@ -4,5 +4,6 @@ from . import views
 
 urlpatterns = [
     url(r'^$', views.index, name='index'),
+    url(r'^(?P<event_id>[0-9]+)/toggleNA/$', views.toggleNA, name='toggleNA'),
     url(r'^importMeetups/$', views.importMeetups, name='importMeetups'),
 ]

Modified: comdev/tools/events_list/views.py
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/views.py?rev=1684098&r1=1684097&r2=1684098&view=diff
==============================================================================
--- comdev/tools/events_list/views.py (original)
+++ comdev/tools/events_list/views.py Mon Jun  8 06:30:54 2015
@@ -1,4 +1,4 @@
-from django.shortcuts import get_object_or_404, render
+from django.shortcuts import get_object_or_404, render, redirect
 from django.http import HttpResponse
 from django.template import RequestContext, loader
 from events_list.models import Event, Group
@@ -12,14 +12,24 @@ 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]
+    upcoming_events_list = Event.objects.filter(is_applicable = True).filter(local_start__gte=now).order_by('local_start')[:20]
     template = loader.get_template('events/index.html')
     context = RequestContext(request, {
                              'upcoming_events_list': upcoming_events_list,
     })
     return HttpResponse(template.render(context))
 
+def toggleNA(request, event_id):
+    # toggle the is_applicable field on a given record
+    event = get_object_or_404(Event, pk = event_id)
+    event.is_applicable = not event.is_applicable
+    event.save()
+
+    return redirect('events_list.views.index')
+    
 def importMeetups(request):
+    # Import latest meetups from meetup.com
+    
     print "Rounding up the ponies ..."
 
     # Note that this API key is *my* API key (rbowen) and if we start using



Mime
View raw message