Esempio n. 1
0
 def put(self, request, pk, format=None):
     casting_request = self.get_object(pk)
     serializer = CastingRequestSerializer(casting_request,
                                           data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response({'error': serializer.errors},
                     status=status.HTTP_400_BAD_REQUEST)
Esempio n. 2
0
 def put(self, request, pk, format=None):
     casting_request = self.get_object(pk)
     serializer = CastingRequestSerializer(casting_request, data=request.data)
     if serializer.is_valid():
         serializer.save()
         user = request.user
         if user:
             note = '{client} updated casting reqeust.'.format(client=user.first_name)
             if casting_request.status == 'Requested':
                 note = '{client} submited.'.format(client=user.first_name)
             UserNoteManager.casting_request_logger(None, None, user, note, casting_request)
             
         return Response(serializer.data)
     return Response({'error': serializer.errors}, status=status.HTTP_400_BAD_REQUEST)
Esempio n. 3
0
    def put(self, request, pk, format=None):
        casting_request = self.get_object(pk)
        serializer = CastingRequestSerializer(casting_request,
                                              data=request.data)
        if serializer.is_valid():
            serializer.save()

            agency = request.user
            client_user = casting_request.client.user
            UserNoteManager.casting_request_logger(agency, agency, client_user,
                                                   'updated casting reqeust.',
                                                   casting_request)

            return Response(serializer.data)
        return Response({'error': serializer.errors},
                        status=status.HTTP_400_BAD_REQUEST)
Esempio n. 4
0
class ClientAllInfoSerializer(serializers.ModelSerializer):
    user = GeneralUserSerializer(many=False, read_only=True)
    casting_requests = CastingRequestSerializer(many=True, read_only=True)
    client_teams = TeamSerializer(many=True, read_only=True)

    class Meta:
        model = Client
        fields = ('id', 'user', 'created', 'casting_requests', 'client_teams')
class CastingRequestTalentSerializer(serializers.ModelSerializer):
    casting_request = CastingRequestSerializer(many=False, read_only=True)
    talent = TalentForCastingRequestSerializer(many=False, read_only=True)

    class Meta:
        model = CastingRequestTalent
        fields = ('id', 'casting_request', 'talent', 'rehearsal_wage',
                  'performance_wage', 'comment', 'created')
Esempio n. 6
0
class CastingRequestList(APIView):
    """
    Retrieve all casting requests.
    """
    @swagger_auto_schema(responses={200: CastingRequestSerializer(many=True)})
    def get(self, request, format=None):
        user = User.objects.get(pk=request.user.pk)
        casting_requests = CastingRequest.objects.all()
        serializer = CastingRequestSerializer(casting_requests, many=True)
        return Response(serializer.data)
Esempio n. 7
0
class CastingRequestDetail(APIView):
    """
    Retrieve, update or delete a casting request
    """
    def get_object(self, pk):
        try:
            return CastingRequest.objects.get(pk=pk)
        except CastingRequest.DoesNotExist:
            raise Http404

    @swagger_auto_schema(responses={200: CastingRequestDetailSerializer(many=False)})
    def get(self, request, pk, format=None):
        casting_request = self.get_object(pk)
        serializer = CastingRequestDetailSerializer(casting_request)
        return Response(serializer.data)

    @swagger_auto_schema(request_body=CastingRequestSerializer,
                         responses={200: CastingRequestSerializer(many=False)})
    def put(self, request, pk, format=None):
        casting_request = self.get_object(pk)
        serializer = CastingRequestSerializer(casting_request, data=request.data)
        if serializer.is_valid():
            serializer.save()

            agency = request.user
            client_user = casting_request.client.user
            UserNoteManager.casting_request_logger(
                agency, agency, client_user, 
                'updated casting reqeust.',
                casting_request
            )

            return Response(serializer.data)
        return Response({'error': serializer.errors}, status=status.HTTP_400_BAD_REQUEST)

    @swagger_auto_schema(responses={200: 'OK'})
    def delete(self, request, pk, format=None):
        casting_request = self.get_object(pk)

        agency = request.user
        client_user = casting_request.client.user
        UserNoteManager.casting_request_logger(
            agency, agency, client_user, 
            'deteled casting reqeust.',
            casting_request
        )

        casting_request.delete()

        return Response(status=status.HTTP_204_NO_CONTENT)
Esempio n. 8
0
 def get(self, request, format=None):
     user = User.objects.get(pk=request.user.pk)
     casting_requests = CastingRequest.objects.all()
     serializer = CastingRequestSerializer(casting_requests, many=True)
     return Response(serializer.data)
Esempio n. 9
0
 def get(self, request, format=None):
     user = User.objects.get(pk=request.user.pk)
     client = Client.objects.get(user=user)
     casting_request = CastingRequest.objects.filter(client=client)
     serializer = CastingRequestSerializer(casting_request, many=True)
     return Response(serializer.data)