Exemple #1
0
    def post(self, request, format=None):
        client = self.get_object(request.user)
        serializer = CastingRequestCreateSerializer(data=request.data)
        if serializer.is_valid():
            data = serializer.validated_data
            new_casting_request = CastingRequest.objects.create(
                client=client,
                name=data['name'],
                ship_name=data['ship_name'],
                employment_start_date=data['employment_start_date'],
                employment_end_date=data['employment_end_date'],
                talent_join_date=data['talent_join_date'],
                rehearsal_start_date=data['rehearsal_start_date'],
                rehearsal_end_date=data['rehearsal_end_date'],
                performance_start_date=data['performance_start_date'],
                performance_end_date=data['performance_end_date'],
                visa_requirements=data['visa_requirements'],
                comments=data['comments'])
            new_casting_request.save()
            UserNoteManager.casting_request_logger(
                None, None, client.user,
                '{client} created a new casting reqeust.'.format(
                    client=client.user.first_name,
                    casting_request_id=new_casting_request.id),
                new_casting_request)

            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response({'error': serializer.errors},
                        status=status.HTTP_400_BAD_REQUEST)
Exemple #2
0
 def delete(self, request, pk, format=None):
     casting_request = self.get_object(pk)
     casting_request.delete()
     user = request.user
     if user:
         UserNoteManager.casting_request_logger(
             None, None, user,
             '{client} deleted this casting reqeust.'.format(
                 client=user.first_name), casting_request)
     return Response({'id': int(pk)}, status=status.HTTP_200_OK)
Exemple #3
0
    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)
Exemple #4
0
    def put(self, request, pk, format=None):
        casting_request = self.get_object(pk)

        serializer = CastingRequestSetStatusSerializer(casting_request,
                                                       data=request.data)
        if serializer.is_valid():
            casting_request.status = request.data['status']
            casting_request.status_updated_date = request.data[
                'status_updated_date']
            casting_request.save()

            agency_user = request.user
            if agency_user:
                client_user = casting_request.client.user
                status = casting_request.status
                if status == 'Requested':
                    note = '{client_user} requested.'.format(
                        client_user=client_user.first_name)
                elif status == 'Reviewing':
                    note = 'Reviewing'
                elif status == 'In Progress':
                    note = 'Contracted to confirm request.'
                elif status == 'Accepted.':
                    note = 'Accepted'
                elif status == 'Declined.':
                    note = 'Declined'
                elif status == 'Canceled.':
                    note = '{client_user} canceled.'.format(
                        client_user=client_user)
                elif status == 'Completed':
                    note = 'Completed.'

                UserNoteManager.casting_request_logger(agency_user.first_name,
                                                       client_user,
                                                       client_user, note,
                                                       casting_request)

                casting_request_talents = CastingRequestTalent.objects.filter(
                    casting_request=casting_request)
                if len(casting_request_talents) > 0:
                    for casting_request_talent in casting_request_talents:
                        talent_user = casting_request_talent.talent.user
                        UserNoteManager.casting_request_talent_logger(
                            agency_user.first_name, client_user, talent_user,
                            note, casting_request_talent)

            new_serializer = CastingRequestDetailSerializer(casting_request)
            return Response(new_serializer.data)
            # serializer.save()
            # return Response(serializer.data)
        return Response({'error': serializer.errors},
                        status=status.HTTP_400_BAD_REQUEST)
Exemple #5
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)
Exemple #6
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)