Filled with Data / Addressbook corrections
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, Permission
|
||||
|
||||
|
||||
from django.db.models import Q
|
||||
|
||||
from datetime import datetime
|
||||
from location_field.models import PlainLocationField
|
||||
@@ -78,6 +79,9 @@ class EventParticipation( models.Model ):
|
||||
|
||||
@staticmethod
|
||||
def hasUserSetParticipationForAllEvents( user ):
|
||||
if not EventParticipation.isMember(user):
|
||||
return True
|
||||
|
||||
futurePart = EventParticipation.objects.filter( event__date__gte = datetime.now() )
|
||||
|
||||
maybeObjects = futurePart.filter( user = user ).filter( status = '?' )
|
||||
@@ -86,6 +90,18 @@ class EventParticipation( models.Model ):
|
||||
else:
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def isMember( user ):
|
||||
return user.has_perm('eventplanner.member')
|
||||
|
||||
@staticmethod
|
||||
def isAdmin( user ):
|
||||
return user.has_perm('eventplanner.admin')
|
||||
|
||||
@staticmethod
|
||||
def members():
|
||||
perm = Permission.objects.get( codename='member' )
|
||||
return User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) ).distinct()
|
||||
|
||||
@staticmethod
|
||||
def get_or_create( user , event ):
|
||||
@@ -99,8 +115,9 @@ class EventParticipation( models.Model ):
|
||||
class Meta:
|
||||
unique_together = ("event", "user")
|
||||
permissions = (
|
||||
("change_others_participation", _("Can modify participation status of other users") ),
|
||||
("admin", _("Admin") ),
|
||||
("member", _("Member") ),
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user