From df22b838fa291aee74aead09d54784647a4e2d49 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Sun, 22 Jun 2014 10:33:39 +0200 Subject: [PATCH] Eventplanning: New "needsAction" state --- eventplanner/models.py | 9 ++++--- .../eventplanner/eventplanning_view.html | 9 +++++++ .../templates/eventplanner/events_grid.html | 25 +++++++++++++++---- eventplanner_gcal/google_sync.py | 12 ++++++--- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/eventplanner/models.py b/eventplanner/models.py index 10eed04..64b33c2 100644 --- a/eventplanner/models.py +++ b/eventplanner/models.py @@ -120,7 +120,8 @@ class Event ( models.Model ): class EventParticipation( models.Model ): OPTIONS = ( ('?' , _('?' )), ('Yes', _('Yes')), - ('No' , _('No' )) + ('No' , _('No' )), + ('-' , _( '-' )) ) event = models.ForeignKey( Event, verbose_name=_("event") ) @@ -149,8 +150,8 @@ class EventParticipation( models.Model ): futurePart = EventParticipation.objects.filter( event__date__gte = datetime.now() ) - maybeObjects = futurePart.filter( user = user ).filter( status = '?' ) - if len( maybeObjects ) > 0: + notYetEntered = futurePart.filter( user = user ).filter( status = '-' ) + if len( notYetEntered ) > 0: return False else: return True @@ -175,7 +176,7 @@ class EventParticipation( models.Model ): try: result = EventParticipation.objects.get( event = event, user = user ) except EventParticipation.DoesNotExist: - result = EventParticipation.objects.create( event = event, user = user, status='?', comment = '' ) + result = EventParticipation.objects.create( event = event, user = user, status='-', comment = '' ) return result diff --git a/eventplanner/templates/eventplanner/eventplanning_view.html b/eventplanner/templates/eventplanner/eventplanning_view.html index 7539ea6..ef07ef1 100644 --- a/eventplanner/templates/eventplanner/eventplanning_view.html +++ b/eventplanner/templates/eventplanner/eventplanning_view.html @@ -180,6 +180,15 @@

Termine

+ +
+ Es gibt jetzt einen vierten Zustand "nicht eingetragen", angezeigt durch nur + blaue Buttons.
+ + "?" bedeutet jetzt: Ich habe mich eingetragen weiss aber noch nicht ob ich komme. + Bitte nur selten benutzen! +
+
diff --git a/eventplanner/templates/eventplanner/events_grid.html b/eventplanner/templates/eventplanner/events_grid.html index 05eb7ab..69209fe 100644 --- a/eventplanner/templates/eventplanner/events_grid.html +++ b/eventplanner/templates/eventplanner/events_grid.html @@ -71,10 +71,14 @@ } else if ( $(this).data('status') == "No" ) { + $(this).data( "status", "-" ); + $(this).children("span.text").html("-"); + } else if ( $(this).data('status') == "-" ) + { $(this).data( "status", "Yes" ) .addClass("btn-success"); $(this).children("span.text").html("Ja"); - } + } $('#saveButton').removeAttr('disabled'); }); @@ -132,11 +136,18 @@
-
+

Termine

- + +
+ Es gibt jetzt einen vierten Zustand "nicht eingetragen", angezeigt durch "-".
+ + "?" bedeutet jetzt: Ich habe mich eingetragen weiss aber noch nicht ob ich komme. + Bitte nur selten benutzen! +
+
@@ -179,10 +190,14 @@ - {% else %} - + {% else %} + {% endif %} {% else %} diff --git a/eventplanner_gcal/google_sync.py b/eventplanner_gcal/google_sync.py index 57f3894..2ff1ffb 100644 --- a/eventplanner_gcal/google_sync.py +++ b/eventplanner_gcal/google_sync.py @@ -59,13 +59,15 @@ def buildGCalAttendeesObj( event ): for userMapping in UserGCalCoupling.objects.all(): u = userMapping.user participation = EventParticipation.get_or_create( u, event ) - status = "tentative" + + status = "needsAction" + if participation.status == "?" : status = "tentative" if participation.status == 'Yes': status = "accepted" if participation.status == 'No' : status = "declined" o = { 'id': userMapping.email, - 'email': u.email, + 'email': userMapping.email, 'displayName': u.username, 'comment': participation.comment, 'responseStatus': status, @@ -253,12 +255,14 @@ def syncFromGoogleToLocal( service = None ): localId = e['extendedProperties']['private']['blechreizID'] localEvent = Event.objects.get( pk=localId ) for a in e['attendees']: - user = User.objects.get( email= a['email'] ) + user = UserGCalCoupling.objects.get( email = a['email'] ).user part = EventParticipation.get_or_create( user, localEvent ) if 'comment' in a: part.comment = a['comment'] - if a['responseStatus'] == 'needsAction' or a['responseStatus']=='tentative': + if a['responseStatus'] == 'needsAction' : + part.status = "-" + elif a['responseStatus']=='tentative': part.status = '?' elif a['responseStatus'] == 'accepted': part.status = 'Yes'