Commit 6ecb419f authored by Gijs Hendriksen's avatar Gijs Hendriksen
Browse files

Add the Google Maps url to the events api

parent 60a089c3
...@@ -13,6 +13,7 @@ from events.exceptions import RegistrationError ...@@ -13,6 +13,7 @@ from events.exceptions import RegistrationError
from events.models import Event, Registration, RegistrationInformationField from events.models import Event, Registration, RegistrationInformationField
from pizzas.models import PizzaEvent from pizzas.models import PizzaEvent
from thaliawebsite.templatetags.bleach_tags import bleach from thaliawebsite.templatetags.bleach_tags import bleach
from utils.snippets import create_google_maps_url
class CalenderJSSerializer(serializers.ModelSerializer): class CalenderJSSerializer(serializers.ModelSerializer):
...@@ -114,7 +115,8 @@ class EventRetrieveSerializer(serializers.ModelSerializer): ...@@ -114,7 +115,8 @@ class EventRetrieveSerializer(serializers.ModelSerializer):
'cancel_deadline', 'location', 'map_location', 'price', 'cancel_deadline', 'location', 'map_location', 'price',
'fine', 'max_participants', 'num_participants', 'status', 'fine', 'max_participants', 'num_participants', 'status',
'user_registration', 'registration_allowed', 'user_registration', 'registration_allowed',
'no_registration_message', 'has_fields', 'is_pizza_event') 'no_registration_message', 'has_fields', 'is_pizza_event',
'google_maps_url')
description = serializers.SerializerMethodField('_description') description = serializers.SerializerMethodField('_description')
user_registration = serializers.SerializerMethodField('_user_registration') user_registration = serializers.SerializerMethodField('_user_registration')
...@@ -123,6 +125,7 @@ class EventRetrieveSerializer(serializers.ModelSerializer): ...@@ -123,6 +125,7 @@ class EventRetrieveSerializer(serializers.ModelSerializer):
'_registration_allowed') '_registration_allowed')
has_fields = serializers.SerializerMethodField('_has_fields') has_fields = serializers.SerializerMethodField('_has_fields')
is_pizza_event = serializers.SerializerMethodField('_is_pizza_event') is_pizza_event = serializers.SerializerMethodField('_is_pizza_event')
google_maps_url = serializers.SerializerMethodField('_google_maps_url')
status = serializers.SerializerMethodField('_status') # DEPRECATED status = serializers.SerializerMethodField('_status') # DEPRECATED
REGISTRATION_NOT_NEEDED = -1 REGISTRATION_NOT_NEEDED = -1
...@@ -181,6 +184,9 @@ class EventRetrieveSerializer(serializers.ModelSerializer): ...@@ -181,6 +184,9 @@ class EventRetrieveSerializer(serializers.ModelSerializer):
def _is_pizza_event(self, instance): def _is_pizza_event(self, instance):
return instance.is_pizza_event() return instance.is_pizza_event()
def _google_maps_url(self, instance):
return create_google_maps_url(instance.map_location, zoom=13, size='450x250')
class EventListSerializer(serializers.ModelSerializer): class EventListSerializer(serializers.ModelSerializer):
"""Custom list serializer for events""" """Custom list serializer for events"""
......
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