kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
See #890: assign report to moderator on resolution
rodzic
05e36c745c
commit
daad6a5dc4
|
@ -488,6 +488,14 @@ class ManageReportViewSet(
|
||||||
required_scope = "instance:reports"
|
required_scope = "instance:reports"
|
||||||
ordering_fields = ["id", "creation_date", "handled_date"]
|
ordering_fields = ["id", "creation_date", "handled_date"]
|
||||||
|
|
||||||
|
def perform_update(self, serializer):
|
||||||
|
is_handled = serializer.instance.is_handled
|
||||||
|
if not is_handled and serializer.validated_data.get("is_handled") is True:
|
||||||
|
# report was resolved, we assign to the mod making the request
|
||||||
|
serializer.save(assigned_to=self.request.user.actor)
|
||||||
|
else:
|
||||||
|
serializer.save()
|
||||||
|
|
||||||
|
|
||||||
class ManageNoteViewSet(
|
class ManageNoteViewSet(
|
||||||
mixins.ListModelMixin,
|
mixins.ListModelMixin,
|
||||||
|
|
|
@ -495,3 +495,17 @@ def test_report_update(factories, superuser_api_client):
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
report.refresh_from_db()
|
report.refresh_from_db()
|
||||||
assert report.is_handled is True
|
assert report.is_handled is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_report_update_is_handled_true_assigns(factories, superuser_api_client):
|
||||||
|
actor = superuser_api_client.user.create_actor()
|
||||||
|
report = factories["moderation.Report"]()
|
||||||
|
url = reverse(
|
||||||
|
"api:v1:manage:moderation:reports-detail", kwargs={"uuid": report.uuid}
|
||||||
|
)
|
||||||
|
response = superuser_api_client.patch(url, {"is_handled": True})
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
report.refresh_from_db()
|
||||||
|
assert report.is_handled is True
|
||||||
|
assert report.assigned_to == actor
|
||||||
|
|
Ładowanie…
Reference in New Issue