|
2 | 2 | import uuid |
3 | 3 |
|
4 | 4 | from core.util.thread_local import get_current_user |
5 | | -from django.db import transaction |
6 | 5 | from event.presentation.models import Presentation, PresentationSpeaker |
7 | 6 | from file.models import PublicFile |
8 | 7 | from participant_portal_api.serializers.modification_audit import ModificationAuditCreationPortalSerializer |
@@ -71,27 +70,22 @@ def to_representation(self, instance): |
71 | 70 |
|
72 | 71 | return result |
73 | 72 |
|
74 | | - def create(self, validated_data): |
75 | | - raise NotImplementedError("Creation of presentations is not allowed in the participant portal.") |
| 73 | + def validate(self, attrs: dict) -> dict: |
| 74 | + attrs = super().validate(attrs) |
76 | 75 |
|
77 | | - @transaction.atomic |
78 | | - def update(self, presentation, validated_data): |
79 | | - speakers = typing.cast(list[PresentationSpeakerPortalData], validated_data["speakers"]) |
| 76 | + speakers = typing.cast(list[PresentationSpeakerPortalData], attrs["speakers"]) |
80 | 77 | if not isinstance(speakers, list): |
81 | 78 | raise serializers.ValidationError("Speakers must be a list.") |
82 | 79 |
|
83 | 80 | for speaker_data in speakers: |
84 | 81 | if not (speaker_instance := self.get_speaker_instance(speaker_data["id"])): |
85 | | - raise serializers.ValidationError( |
86 | | - f"Speaker with ID {speaker_data['id']} not found or does not belong to this presentation." |
87 | | - ) |
| 82 | + err_msg = f"Speaker with ID {speaker_data['id']} not found or does not belong to this presentation." |
| 83 | + raise serializers.ValidationError(err_msg) |
88 | 84 |
|
89 | | - speaker_serializer = PresentationSpeakerPortalSerializer( |
| 85 | + PresentationSpeakerPortalSerializer( |
90 | 86 | instance=speaker_instance, |
91 | 87 | data=speaker_data, |
92 | 88 | partial=True, |
93 | | - ) |
94 | | - speaker_serializer.is_valid(raise_exception=True) |
95 | | - speaker_serializer.save() |
| 89 | + ).is_valid(raise_exception=True) |
96 | 90 |
|
97 | | - return super().update(presentation, validated_data) |
| 91 | + return attrs |
0 commit comments