-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify report views #1872
Simplify report views #1872
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -148,14 +148,11 @@ def related(self, request, identifier=None, *_, **__): | |||
serializer = self.get_serializer(results, many=True) | ||||
return self.get_paginated_response(serializer.data) | ||||
|
||||
def report(self, request, *_, **__): | ||||
media = self.get_object() | ||||
identifier = media.identifier | ||||
def report(self, request, identifier): | ||||
serializer = self.get_serializer(data=request.data | {"identifier": identifier}) | ||||
serializer.is_valid(raise_exception=True) | ||||
report = serializer.save() | ||||
serializer.save() | ||||
|
||||
serializer = self.get_serializer(report) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what was going on in the original code here 🤔 But the changes look good to me! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be the original author assumed that the serializer's data wouldn't be updated if the underlying object changed during
Anyway, that's just a guess. I'm not sure what Django's behaviour is when saving the serializer changes the underlying data (due to the model's |
||||
return Response(data=serializer.data, status=status.HTTP_201_CREATED) | ||||
|
||||
def thumbnail(self, image_url, request, *_, **__): | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this would be clearer if the status check was before the query on line 238 and caused an early return? Something like:
Only because then it is quite clear that the intention is that pending reports should have no effect on other reports.