Verified Commit c21f838f authored by Gijs Hendriksen's avatar Gijs Hendriksen Committed by Sébastiaan Versteeg
Browse files

Added pizza field to serializer

parent d2b73133
......@@ -4,6 +4,7 @@ from django.utils.html import strip_tags
from rest_framework import serializers
from events.models import Event, Registration
from pizzas.models import PizzaEvent
from thaliawebsite.settings import settings
......@@ -142,10 +143,11 @@ class EventListSerializer(serializers.ModelSerializer):
class Meta:
model = Event
fields = ('pk', 'title', 'description', 'start', 'end',
'location', 'price', 'registered')
'location', 'price', 'registered', 'pizza')
description = serializers.SerializerMethodField('_description')
registered = serializers.SerializerMethodField('_registered')
pizza = serializers.SerializerMethodField('_pizza')
def _description(self, instance):
return strip_tags(instance.description)
......@@ -157,6 +159,10 @@ class EventListSerializer(serializers.ModelSerializer):
except AttributeError:
return None
def _pizza(self, instance):
pizza_events = PizzaEvent.objects.filter(event=instance)
return pizza_events.exists()
class EventRegistrationSerializer(serializers.ModelSerializer):
class Meta:
......
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