API: Expose organizer and event URL (Z#23116269) (#3121)

This commit is contained in:
Martin Gross
2023-02-14 14:47:18 +01:00
committed by GitHub
parent e33fbaf9c0
commit 20581cd31c
7 changed files with 47 additions and 14 deletions

View File

@@ -59,6 +59,7 @@ from pretix.base.settings import (
LazyI18nStringList, validate_event_settings,
)
from pretix.base.signals import api_event_settings_fields
from pretix.multidomain.urlreverse import build_absolute_uri
logger = logging.getLogger(__name__)
@@ -164,6 +165,10 @@ class EventSerializer(I18nAwareModelSerializer):
timezone = TimeZoneField(required=False, choices=[(a, a) for a in common_timezones])
valid_keys = ValidKeysField(source='*', read_only=True)
best_availability_state = serializers.IntegerField(allow_null=True, read_only=True)
public_url = serializers.SerializerMethodField('get_event_url', read_only=True)
def get_event_url(self, event):
return build_absolute_uri(event, 'presale:event.index')
class Meta:
model = Event
@@ -171,7 +176,7 @@ class EventSerializer(I18nAwareModelSerializer):
'date_to', 'date_admission', 'is_public', 'presale_start',
'presale_end', 'location', 'geo_lat', 'geo_lon', 'has_subevents', 'meta_data', 'seating_plan',
'plugins', 'seat_category_mapping', 'timezone', 'item_meta_properties', 'valid_keys',
'sales_channels', 'best_availability_state')
'sales_channels', 'best_availability_state', 'public_url')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)