Verified Commit 2aef9874 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Fix issues with the member object in events services

parent 1ebd5f8a
...@@ -7,7 +7,7 @@ from events.models import Registration, RegistrationInformationField ...@@ -7,7 +7,7 @@ from events.models import Registration, RegistrationInformationField
def is_user_registered(event, member): def is_user_registered(event, member):
if not event.registration_required: if not event.registration_required or not member.is_authenticated:
return None return None
return event.registrations.filter( return event.registrations.filter(
...@@ -21,7 +21,7 @@ def event_permissions(member, event): ...@@ -21,7 +21,7 @@ def event_permissions(member, event):
"cancel_registration": False, "cancel_registration": False,
"update_registration": False, "update_registration": False,
} }
if member.is_authenticated and member.can_attend_events: if member and member.is_authenticated and member.can_attend_events:
registration = None registration = None
try: try:
registration = Registration.objects.get( registration = Registration.objects.get(
...@@ -47,15 +47,16 @@ def event_permissions(member, event): ...@@ -47,15 +47,16 @@ def event_permissions(member, event):
def is_organiser(member, event): def is_organiser(member, event):
if member.is_superuser or member.has_perm("events.override_organiser"): if member and member.is_authenticated:
return True if member.is_superuser or member.has_perm("events.override_organiser"):
return True
if event and member.has_perm('events.change_event'):
committees = 0 if event and member.has_perm('events.change_event'):
if event is not None: committees = 0
committees = member.get_committees().filter( if event is not None:
pk=event.organiser.pk).count() committees = member.get_committees().filter(
return committees != 0 pk=event.organiser.pk).count()
return committees != 0
return False return False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment