Пример #1
0
    def delete(self, request, slug_project, database_object_project,
               id_message, use_sandbox):
        Manager_Messages_Reject.delete_from_project(
            id_message=id_message,
            database_object_project=database_object_project,
        )

        return Response(status=status.HTTP_204_NO_CONTENT)
Пример #2
0
    def update(instance, validated_data):
        for key, value in validated_data.items():
            if key == 'message_reject_default':
                message_old = instance.message_reject_default

                if message_old is not None:
                    Manager_Messages_Reject.delete_if_no_usage(message_old)

                if value is None:
                    instance.message_reject_default = None
                else:
                    instance.message_reject_default = MessageReject.objects.get(id=value.get('id'))
            else:
                setattr(instance, key, value)

        instance.save()
        return instance
Пример #3
0
    def create(self, validated_data):
        print('validated_data')
        print(validated_data)

        item = Manager_Messages_Reject.create(
            database_object_project=validated_data.get(
                'database_object_project'),
            data=validated_data)

        return item
Пример #4
0
    def get(self, request):
        queryset = Manager_Messages_Reject.get_all(request=request, )

        queryset_paginated, count_items = paginate_queryset(queryset, request)

        serializer = Serializer_Message_Reject(queryset_paginated,
                                               many=True,
                                               context={'request': request})

        return Response({
            'items_total': count_items,
            'data': serializer.data,
        })