Google calendar sync
This commit is contained in:
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@ from django.db import models
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.contrib.auth.models import User, Permission
|
||||
|
||||
|
||||
from django.db.models import Q
|
||||
|
||||
from datetime import datetime
|
||||
from location_field.models import PlainLocationField
|
||||
|
||||
from django.db.models import Q
|
||||
from django.dispatch import Signal
|
||||
|
||||
|
||||
|
||||
|
||||
class NoNextEventException( Exception ):
|
||||
def __str__(self):
|
||||
@@ -113,7 +115,10 @@ class Event ( models.Model ):
|
||||
|
||||
return nextEvent
|
||||
|
||||
|
||||
|
||||
before_read = Signal()
|
||||
|
||||
|
||||
class EventParticipation( models.Model ):
|
||||
OPTIONS = ( ('?' , _('?' )),
|
||||
('Yes', _('Yes')),
|
||||
@@ -124,7 +129,8 @@ class EventParticipation( models.Model ):
|
||||
user = models.ForeignKey( User, verbose_name=_("user") )
|
||||
status = models.CharField ( max_length=3, choices = OPTIONS, default='?', verbose_name=_("status") )
|
||||
comment = models.CharField ( max_length=64, blank=True, verbose_name=_("comment") )
|
||||
|
||||
|
||||
|
||||
def get_username(self):
|
||||
return self.user.username
|
||||
|
||||
@@ -140,7 +146,11 @@ class EventParticipation( models.Model ):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
@staticmethod
|
||||
def raiseBeforeReadSignal():
|
||||
before_read.send( sender=EventParticipation )
|
||||
|
||||
@staticmethod
|
||||
def isMember( user ):
|
||||
return user.has_perm('eventplanner.member')
|
||||
|
||||
@@ -6,7 +6,6 @@ from django.forms import TextInput
|
||||
|
||||
from models import Event, EventParticipation
|
||||
|
||||
|
||||
from serializers import ParticipationSerializer
|
||||
|
||||
import datetime
|
||||
@@ -62,7 +61,8 @@ def eventplanning( request ):
|
||||
"""
|
||||
View for a specific user, to edit his events
|
||||
"""
|
||||
# non-members see the grid - but cannot edit anything
|
||||
EventParticipation.raiseBeforeReadSignal()
|
||||
# non-members see the grid - but cannot edit anything
|
||||
if not EventParticipation.isMember( request.user ):
|
||||
return events_grid(request)
|
||||
|
||||
@@ -78,6 +78,8 @@ def eventplanning( request ):
|
||||
|
||||
|
||||
def events_grid( request ):
|
||||
EventParticipation.raiseBeforeReadSignal()
|
||||
|
||||
usernames = [ u.username for u in EventParticipation.members() ]
|
||||
|
||||
all_future_events = list ( Event.objects.filter( date__gte = datetime.date.today() ).order_by( 'date') )
|
||||
|
||||
Reference in New Issue
Block a user