class EventAdministrateSerializer(EventReadSerializer): pools = PoolAdministrateSerializer(many=True) unregistered = RegistrationReadDetailedSerializer(many=True) waiting_registrations = RegistrationReadDetailedSerializer(many=True) class Meta(EventReadSerializer.Meta): fields = EventReadSerializer.Meta.fields + ('pools', 'unregistered', 'waiting_registrations')
class EventAdministrateSerializer(EventReadSerializer): pools = PoolAdministrateSerializer(many=True) unregistered = RegistrationReadDetailedSerializer(many=True) waiting_registrations = RegistrationReadDetailedSerializer(many=True) class Meta(EventReadSerializer.Meta): fields = EventReadSerializer.Meta.fields + ( "pools", "unregistered", "waiting_registrations", "use_consent", )
def admin_unregister(self, request, *args, **kwargs): admin_user = request.user event_id = self.kwargs.get("event_pk", None) event = Event.objects.get(id=event_id) serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) try: registration = event.admin_unregister( admin_user=admin_user, **serializer.validated_data ) if ( registration.payment_intent_id and registration.payment_status != constants.PAYMENT_SUCCESS ): async_cancel_payment.delay(registration.id) notify_event_registration( constants.SOCKET_UNREGISTRATION_SUCCESS, registration ) except NoSuchRegistration: raise APINoSuchRegistration() except RegistrationExists: raise APIRegistrationExists() reg_data = RegistrationReadDetailedSerializer(registration).data return Response(data=reg_data, status=status.HTTP_200_OK)
def admin_unregister(self, request, *args, **kwargs): event_id = self.kwargs.get('event_pk', None) event = Event.objects.get(id=event_id) serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) try: registration = event.admin_unregister(**serializer.validated_data) except NoSuchRegistration: raise APINoSuchRegistration() except RegistrationExists: raise APIRegistrationExists() reg_data = RegistrationReadDetailedSerializer(registration).data return Response(data=reg_data, status=status.HTTP_200_OK)
def admin_register(self, request, *args, **kwargs): event_id = self.kwargs.get("event_pk", None) try: event = Event.objects.get(id=event_id) except Event.DoesNotExist: raise APIEventNotFound() serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) try: registration = event.admin_register(**serializer.validated_data) except NoSuchPool: raise APINoSuchPool() except RegistrationExists: raise APIRegistrationExists() reg_data = RegistrationReadDetailedSerializer(registration).data return Response(data=reg_data, status=status.HTTP_201_CREATED)
class PoolAdministrateSerializer(PoolReadAuthSerializer): registrations = RegistrationReadDetailedSerializer(many=True)