Commit 6efdaced authored by Gijs Hendriksen's avatar Gijs Hendriksen

Resolve 'null' values in events API

parent 8a2cab5c
......@@ -193,10 +193,15 @@ class EventListSerializer(serializers.ModelSerializer):
def _registered(self, instance):
try:
return services.is_user_registered(self.context['request'].user,
instance)
registered = services.is_user_registered(
self.context['request'].user,
instance,
)
if registered is None:
return False
return registered
except AttributeError:
return None
return False
def _pizza(self, instance):
pizza_events = PizzaEvent.objects.filter(event=instance)
......
......@@ -224,13 +224,13 @@ class Event(models.Model, metaclass=ModelTranslateMeta):
@property
def registration_allowed(self):
now = timezone.now()
return ((self.registration_start or self.registration_end) and
self.registration_end > now >= self.registration_start)
return (bool(self.registration_start or self.registration_end)
and self.registration_end > now >= self.registration_start)
@property
def cancellation_allowed(self):
now = timezone.now()
return ((self.registration_start or self.registration_end)
return (bool(self.registration_start or self.registration_end)
and self.registration_start <= now < self.start)
def is_pizza_event(self):
......
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