Commit f6a16166 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'pizza-events-in-event-serializer' into 'master'

Add field for pizza events to the Event serializer

See merge request thalia/concrexit!687
parents bac5e072 a0736213
......@@ -107,7 +107,7 @@ class EventRetrieveSerializer(serializers.ModelSerializer):
'cancel_deadline', 'location', 'map_location', 'price',
'fine', 'max_participants', 'num_participants', 'status',
'user_registration', 'registration_allowed',
'no_registration_message', 'has_fields')
'no_registration_message', 'has_fields', 'is_pizza_event')
description = serializers.SerializerMethodField('_description')
user_registration = serializers.SerializerMethodField('_user_registration')
......@@ -115,6 +115,7 @@ class EventRetrieveSerializer(serializers.ModelSerializer):
registration_allowed = serializers.SerializerMethodField(
'_registration_allowed')
has_fields = serializers.SerializerMethodField('_has_fields')
is_pizza_event = serializers.SerializerMethodField('_is_pizza_event')
status = serializers.SerializerMethodField('_status') # DEPRECATED
REGISTRATION_NOT_NEEDED = -1
......@@ -170,6 +171,9 @@ class EventRetrieveSerializer(serializers.ModelSerializer):
def _has_fields(self, instance):
return instance.has_fields()
def _is_pizza_event(self, instance):
return instance.is_pizza_event()
class EventListSerializer(serializers.ModelSerializer):
class Meta:
......
from django.core import validators
from django.core.exceptions import ValidationError
from django.core.exceptions import ValidationError, ObjectDoesNotExist
from django.db import models
from django.db.models import Q
from django.urls import reverse
......@@ -187,6 +187,13 @@ class Event(models.Model, metaclass=ModelTranslateMeta):
return ((self.registration_start or self.registration_end)
and now >= self.registration_start)
def is_pizza_event(self):
try:
self.pizzaevent
return True
except ObjectDoesNotExist:
return False
def clean(self):
super().clean()
errors = {}
......
Supports Markdown
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