Junior
Changing feedback status with email notification
livecode
Task condition
There is an API controller CreateFeedbackAPIView that creates a Feedback object and then asynchronously starts the change_status_feedback task. The task updates the feedback status and calls the send_mail() function. Conduct a code review and identify syntax errors. Ensure that the code works correctly with the Celery task, serialization, and object saving.
@app.task(name='change_status_feedback')
def change_status_feedback(feedback):
feedback.status = 'in_progress'
send_mail()
feedback.save()
class CreateFeedbackAPIView(APIView):
def create(self, request):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
feedback = Feedback.objects.create(**serializer.validated_data)
change_status_feedback.delay(feedback)
return feedback