You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
872 B
23 lines
872 B
from rest_framework import serializers
|
|
from .models import Event, EventApplication
|
|
from divebases.serializers import DiveBaseSerializer
|
|
from users.serializers import UserSerializer
|
|
|
|
class EventSerializer(serializers.ModelSerializer):
|
|
dive_base = DiveBaseSerializer(read_only=True)
|
|
|
|
class Meta:
|
|
model = Event
|
|
fields = ['id', 'title', 'start_datetime', 'location', 'google_maps_link',
|
|
'description', 'payment_details', 'dive_base', 'is_deleted']
|
|
|
|
class EventApplicationSerializer(serializers.ModelSerializer):
|
|
user = UserSerializer(read_only=True)
|
|
event_id = serializers.PrimaryKeyRelatedField(
|
|
source='event', queryset=Event.objects.all(), write_only=True
|
|
)
|
|
|
|
class Meta:
|
|
model = EventApplication
|
|
fields = ['id', 'event', 'event_id', 'user', 'paid']
|
|
read_only_fields = ['id', 'user']
|
|
|