diff --git a/api/funkwhale_api/moderation/dynamic_preferences_registry.py b/api/funkwhale_api/moderation/dynamic_preferences_registry.py index fbbcd6a61..bda9b5952 100644 --- a/api/funkwhale_api/moderation/dynamic_preferences_registry.py +++ b/api/funkwhale_api/moderation/dynamic_preferences_registry.py @@ -1,3 +1,4 @@ +import pycountry from dynamic_preferences import types from dynamic_preferences.registries import global_preferences_registry from rest_framework import serializers @@ -92,3 +93,18 @@ class SignupFormCustomization(common_preferences.SerializedPreference): required = False default = {} data_serializer_class = CustomFormSerializer + + +@global_preferences_registry.register +class Languages(common_preferences.StringListPreference): + show_in_api = True + section = moderation + name = "languages" + default = ["en"] + verbose_name = "Moderation languages" + help_text = ( + "The language(s) spoken by the server moderator(s). Set this to inform users " + "what languages they should write reports and requests in." + ) + choices = [(lang.alpha_3, lang.name) for lang in pycountry.languages] + field_kwargs = {"choices": choices, "required": False} diff --git a/api/poetry.lock b/api/poetry.lock index 27109801c..9c94730b7 100644 --- a/api/poetry.lock +++ b/api/poetry.lock @@ -2725,6 +2725,19 @@ files = [ {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"}, ] +[[package]] +name = "pycountry" +version = "22.3.5" +description = "ISO country, subdivision, language, currency and script definitions and their translations" +optional = false +python-versions = ">=3.6, <4" +files = [ + {file = "pycountry-22.3.5.tar.gz", hash = "sha256:b2163a246c585894d808f18783e19137cb70a0c18fb36748dc01fc6f109c1646"}, +] + +[package.dependencies] +setuptools = "*" + [[package]] name = "pycparser" version = "2.21" @@ -4536,4 +4549,4 @@ typesense = ["typesense"] [metadata] lock-version = "2.0" python-versions = "^3.8,<3.12" -content-hash = "89defcf9df569a1d3e2cdb50b29fd9161288dc88daa8c3e0e574ace88d196db2" +content-hash = "5a259657d79f98ce6a7c377c5715aaf6f56d7ad4b9c420e784c81aa145c86b1d" diff --git a/api/pyproject.toml b/api/pyproject.toml index 3efe52293..4f9bde163 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -87,6 +87,7 @@ watchdog = "==2.2.1" troi = { git = "https://github.com/metabrainz/troi-recommendation-playground.git", tag = "v-2023-10-30.0"} lb-matching-tools = { git = "https://github.com/metabrainz/listenbrainz-matching-tools.git", branch = "main"} unidecode = "==1.3.6" +pycountry = "22.3.5" # Typesense typesense = { version = "==0.15.1", optional = true } diff --git a/changes/changelog.d/moderation-languages.feature b/changes/changelog.d/moderation-languages.feature new file mode 100644 index 000000000..2adca49fe --- /dev/null +++ b/changes/changelog.d/moderation-languages.feature @@ -0,0 +1 @@ +Allow moderators to set moderation languages (#2085) diff --git a/front/src/views/admin/Settings.vue b/front/src/views/admin/Settings.vue index 1ff48b2bc..1d36566d1 100644 --- a/front/src/views/admin/Settings.vue +++ b/front/src/views/admin/Settings.vue @@ -80,6 +80,7 @@ const groups = computed(() => [ label: t('views.admin.Settings.header.moderation'), id: 'moderation', settings: [ + { name: 'moderation__languages' }, { name: 'moderation__allow_list_enabled' }, { name: 'moderation__allow_list_public' }, { name: 'moderation__unauthenticated_report_types' }