From d7705593a9b97992f54038a503aa81af7f730f03 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Tue, 27 Aug 2019 13:49:54 +0200 Subject: [PATCH] See #890: added table to list reports --- api/funkwhale_api/common/filters.py | 14 +- api/funkwhale_api/manage/filters.py | 5 +- front/src/components/Sidebar.vue | 2 +- front/src/router/index.js | 16 +- .../views/admin/moderation/ReportsList.vue | 268 ++++++++++++++++++ 5 files changed, 299 insertions(+), 6 deletions(-) create mode 100644 front/src/views/admin/moderation/ReportsList.vue diff --git a/api/funkwhale_api/common/filters.py b/api/funkwhale_api/common/filters.py index 364a1fba1..58244b67f 100644 --- a/api/funkwhale_api/common/filters.py +++ b/api/funkwhale_api/common/filters.py @@ -15,7 +15,7 @@ class NoneObject(object): NONE = NoneObject() -NULL_BOOLEAN_CHOICES = [ +BOOLEAN_CHOICES = [ (True, True), ("true", True), ("True", True), @@ -26,6 +26,8 @@ NULL_BOOLEAN_CHOICES = [ ("False", False), ("0", False), ("no", False), +] +NULL_BOOLEAN_CHOICES = BOOLEAN_CHOICES + [ ("None", NONE), ("none", NONE), ("Null", NONE), @@ -76,10 +78,18 @@ def clean_null_boolean_filter(v): return v +def clean_boolean_filter(v): + return CoerceChoiceField(choices=BOOLEAN_CHOICES).clean(v) + + def get_null_boolean_filter(name): return {"handler": lambda v: Q(**{name: clean_null_boolean_filter(v)})} +def get_boolean_filter(name): + return {"handler": lambda v: Q(**{name: clean_boolean_filter(v)})} + + class DummyTypedMultipleChoiceField(forms.TypedMultipleChoiceField): def valid_value(self, value): return True @@ -142,7 +152,7 @@ class MutationFilter(filters.FilterSet): "domain": {"to": "created_by__domain__name__iexact"}, "is_approved": get_null_boolean_filter("is_approved"), "target": {"handler": filter_target}, - "is_applied": {"to": "is_applied"}, + "is_applied": get_boolean_filter("is_applied"), }, ) ) diff --git a/api/funkwhale_api/manage/filters.py b/api/funkwhale_api/manage/filters.py index 6ea3b8c99..59577cd39 100644 --- a/api/funkwhale_api/manage/filters.py +++ b/api/funkwhale_api/manage/filters.py @@ -5,6 +5,7 @@ import django_filters from django_filters import rest_framework as filters from funkwhale_api.common import fields +from funkwhale_api.common import filters as common_filters from funkwhale_api.common import search from funkwhale_api.federation import models as federation_models @@ -348,9 +349,9 @@ class ManageReportFilterSet(filters.FilterSet): filter_fields={ "uuid": {"to": "uuid"}, "id": {"to": "id"}, - "is_handled": {"to": "is_handled"}, + "resolved": common_filters.get_boolean_filter("is_handled"), "domain": {"to": "target_owner__domain_id"}, - "type": {"to": "type"}, + "category": {"to": "type"}, "submitter": get_actor_filter("submitter"), "assigned_to": get_actor_filter("assigned_to"), "target_owner": get_actor_filter("target_owner"), diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue index 6f72a9c2f..6d9e0c0ec 100644 --- a/front/src/components/Sidebar.vue +++ b/front/src/components/Sidebar.vue @@ -93,7 +93,7 @@ + :to="{name: 'manage.moderation.reports.list'}"> Moderation
+ import( + /* webpackChunkName: "admin" */ "@/views/admin/moderation/ReportsList" + ), + props: route => { + return { + defaultQuery: route.query.q, + updateUrl: true + } + } + }, ] }, { diff --git a/front/src/views/admin/moderation/ReportsList.vue b/front/src/views/admin/moderation/ReportsList.vue new file mode 100644 index 000000000..d5781e1b4 --- /dev/null +++ b/front/src/views/admin/moderation/ReportsList.vue @@ -0,0 +1,268 @@ + + + + + +