mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-18 13:34:08 +01:00
Incorrect model in subtask serializer and add PUT PATCH for subtask
This commit is contained in:
parent
f9e1250c56
commit
cfccebf189
@ -107,4 +107,4 @@ class SubTaskSerializer(serializers.ModelSerializer):
|
||||
|
||||
def create(self, validated_data):
|
||||
# Create a new task with validated data
|
||||
return Todo.objects.create(**validated_data)
|
||||
return Subtask.objects.create(**validated_data)
|
||||
@ -130,7 +130,8 @@ list=extend_schema(
|
||||
class SubTaskViewset(viewsets.GenericViewSet,
|
||||
mixins.CreateModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
mixins.ListModelMixin):
|
||||
mixins.ListModelMixin,
|
||||
mixins.UpdateModelMixin):
|
||||
queryset = Subtask.objects.all()
|
||||
permission_classes = (IsAuthenticated,)
|
||||
|
||||
@ -173,6 +174,19 @@ class SubTaskViewset(viewsets.GenericViewSet,
|
||||
return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
|
||||
def partial_update(self, request, *args, **kwargs):
|
||||
"""Update a subtask."""
|
||||
try:
|
||||
instance = self.get_o
|
||||
serializer = self.get_serializer(instance, data=request.data, partial=True)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
self.perform_update(serializer)
|
||||
return Response(serializer.data)
|
||||
|
||||
except Exception as e:
|
||||
return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
|
||||
class RecurrenceTaskViewSet(viewsets.ModelViewSet):
|
||||
queryset = RecurrenceTask.objects.all()
|
||||
serializer_class = RecurrenceTaskSerializer
|
||||
|
||||
Loading…
Reference in New Issue
Block a user