Select Git revision
serializers.py
ThomasBidot
authored and
GitHub
committed
* Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin * Added school info * Fixed typo in filters * Sorties (#30) * Custom participation_inline css * Ordered student profiles by last modification date in admin * Ajouté infos sorties * Sortie thomas (#32) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Sortie thomas (export CSV sorties) (#33) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Ajout export CSV sorties Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Dylan Sechet <dylan.sechet82@gmail.com> Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Update runtime.txt Changement version python * Ordering students by updated_date * Notifications for Sec-Gen (#35) * Custom participation_inline css * Ajout filtre sur register * Ajout filtre participation * Ordered student profiles by last modification date in admin * Ajouté infos sorties * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Sortie thomas (#32) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Ajout export CSV sorties * Sortie thomas (export CSV sorties) (#33) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Ajout export CSV sorties Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> * Erreurs dans visits/admin résolus * Notifications for Sec-Gen Co-authored-by:
Dylan Sechet <dylan.sechet82@gmail.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Add context_sheet for visits (#37) * Custom participation_inline css * Ajout filtre sur register * Ajout filtre participation * Ordered student profiles by last modification date in admin * Ajouté infos sorties * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Sortie thomas (#32) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Ajout export CSV sorties * Sortie thomas (export CSV sorties) (#33) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Ajout export CSV sorties Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> * Erreurs dans visits/admin résolus * Notifications for Sec-Gen * Add conext_sheet for visits * Add context_sheet for visits V2 * Add context_sheet for visits V3 Co-authored-by:
Dylan Sechet <dylan.sechet82@gmail.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Add context sheet for visits V4 (#38) * Custom participation_inline css * Ajout filtre sur register * Ajout filtre participation * Ordered student profiles by last modification date in admin * Ajouté infos sorties * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Sortie thomas (#32) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Ajout export CSV sorties * Sortie thomas (export CSV sorties) (#33) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Ajout export CSV sorties Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> * Erreurs dans visits/admin résolus * Notifications for Sec-Gen * Add conext_sheet for visits * Add context_sheet for visits V2 * Add context_sheet for visits V3 * Add context_sheet for visits V4 Co-authored-by:
Dylan Sechet <dylan.sechet82@gmail.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Version correction of psycopg2 and tornado * Solve public permission files on AWS (#39) * Custom participation_inline css * Ajout filtre sur register * Ajout filtre participation * Ordered student profiles by last modification date in admin * Ajouté infos sorties * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Sortie thomas (#32) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> * Ajout export CSV sorties * Sortie thomas (export CSV sorties) (#33) * Updated student admin filters (#28) * Password reset feature (#8) * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * Add Django Rest auth module * Try to make the send reset password email work * Modified template mail for reset * test * Added utf-8 support to exported csv and switched delimiter from , to ; in admin interface * Disabled emails while in dev * Added multi selection filter in admin * Fixed mail settings * Added year field to Tutor serializer * Fixed year updated before registration form filled * commit for automatic deploy * Testing CI * Added filtering in admin for registration validation * Added filter to student admin Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> * Ajout filtre sur register * Ajout filtre participation * Ajout de 3 filtres par etablissements * Ajout 3 filtres pour etablissement V2 * Ajout export CSV sorties Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> * Erreurs dans visits/admin résolus * Notifications for Sec-Gen * Add conext_sheet for visits * Add context_sheet for visits V2 * Add context_sheet for visits V3 * Add context_sheet for visits V4 * Solve public permission files on AWS Co-authored-by:
Dylan Sechet <dylan.sechet82@gmail.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com> Co-authored-by:
chiahetcho <44137047+chiahetcho@users.noreply.github.com> Co-authored-by:
florimondmanca <florimond.manca@gmail.com> Co-authored-by:
Dylan Sechet <dylan.sechet82@gmail.com> Co-authored-by:
Arthur Guédon <arthur.guedon@student-cs.fr> Co-authored-by:
Arthur Guédon <60623551+arthurgdn@users.noreply.github.com> Co-authored-by:
Seon82 <46298009+Seon82@users.noreply.github.com> Co-authored-by:
Bidot-Naude Thomas <thomas.bidotnaude@student-cs.fr> Co-authored-by:
Witeden <58004019+Witeden@users.noreply.github.com>
serializers.py 3.75 KiB
"""Visits serializers."""
from django.utils.timezone import now
from rest_framework import serializers
from core.fields import MarkdownField
from core.serializers import AddressSerializer
from profiles.models import Tutor
from users.fields import UserField
from users.serializers import UserSerializer
from .models import Participation, Place, Visit
from .notifications import ParticipationCancelled
class PlaceSerializer(serializers.ModelSerializer):
"""Serializer for Place."""
description = MarkdownField()
address = AddressSerializer()
class Meta: # noqa
model = Place
fields = ('id', 'name', 'address', 'description')
class ParticipationSerializer(serializers.ModelSerializer):
"""Serializer for visit participations."""
user = UserField(
label='Utilisateur',
help_text='Identifier for the user who participates.')
visit = serializers.PrimaryKeyRelatedField(
queryset=Visit.objects.all(),
label='Sortie',
help_text='Identifier for the associated visit.')
class Meta: # noqa
model = Participation
fields = ('id', 'submitted', 'user', 'visit', 'present', 'accepted',)
class VisitOrganizerSerializer(serializers.ModelSerializer):
"""Serializer for visit organizers."""
user = UserSerializer()
class Meta: # noqa
model = Tutor
fields = ('id', 'user',)
class VisitListSerializer(serializers.HyperlinkedModelSerializer):
"""Serializer for lists of visits."""
place = serializers.StringRelatedField()
participants = ParticipationSerializer(source='participations', many=True)
organizers = serializers.SerializerMethodField()
def get_organizers(self, obj):
return obj.organizers.values_list('user__id', flat=True)
passed = serializers.SerializerMethodField()
def get_passed(self, obj: Visit) -> bool:
"""Return true if the visit already happened, false otherwise."""
now_date = now().date()
if obj.date == now_date:
return now().time() > obj.end_time
return now_date > obj.date
class Meta: # noqa
model = Visit
fields = (
'id', 'title', 'summary',
'place', 'date', 'start_time', 'end_time',
'deadline', 'passed', 'registrations_open',
'participants', 'organizers',
'image', 'url')
extra_kwargs = {'url': {'view_name': 'api:visit-detail'}}
class VisitSerializer(VisitListSerializer):
"""Serializer for Visit."""
place = PlaceSerializer()
organizers = VisitOrganizerSerializer(many=True)
class Meta(VisitListSerializer.Meta): # noqa
depth = 1
fields = (
'id', 'title', 'summary', 'description',
'place', 'date', 'start_time', 'end_time', 'meeting',
'deadline', 'passed', 'registrations_open',
'participants', 'organizers',
'image', 'fact_sheet', 'context_sheet', 'permission',
'url',)
class ParticipationCancelledSerializer(serializers.Serializer):
"""Serializer for sending participation cancelled notifications."""
reason = serializers.CharField(
write_only=True,
label='Reason',
help_text='Explain why the user cancelled their participation.')
sent = serializers.BooleanField(read_only=True)
timestamp = serializers.DateTimeField(read_only=True)
def update(self, instance: Participation, validated_data):
"""Send a notification as the user cancelled their participation."""
reason = validated_data['reason']
notification = ParticipationCancelled(
user=instance.user, visit=instance.visit, reason=reason)
notification.send()
return notification
class Meta: # noqa
model = Participation