Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
Arquivo: views.py Projeto: webkom/lego
 def admin_register(self, request, *args, **kwargs):
     admin_user = request.user
     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(admin_user=admin_user,
                                             **serializer.validated_data)
         notify_event_registration(constants.SOCKET_REGISTRATION_SUCCESS,
                                   registration)
     except NoSuchPool:
         raise APINoSuchPool()
     except RegistrationExists:
         raise APIRegistrationExists()
     reg_data = RegistrationReadDetailedSerializer(registration).data
     return Response(data=reg_data, status=status.HTTP_201_CREATED)