make setting dynamic

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2607>
This commit is contained in:
Petitminion 2023-11-06 00:00:39 +01:00 committed by Marge
commit 179c53695e
8 changed files with 22 additions and 19 deletions

View file

@ -32,3 +32,18 @@ class MusicCacheDuration(types.IntPreference):
"will be erased and retranscoded on the next listening."
)
field_kwargs = {"required": False}
@global_preferences_registry.register
class MbidTaggedContent(types.BooleanPreference):
show_in_api = True
section = music
name = "only_allow_musicbrainz_tagged_files"
verbose_name = "Only allow Musicbrainz tagged files"
help_text = (
"Only Musicbrainz tagged files will be allowed to be uploaded on the server. "
"If files where uploaded before this settings will not affect them. "
"To clean the db from files not following mb tags use the funkwhale cli "
"or use quality filters"
)
default = False

View file

@ -247,10 +247,8 @@ def process_upload(upload, update_denormalization=True):
return fail_import(
upload, "invalid_metadata", detail=detail, file_metadata=metadata_dump
)
if (
settings.ONLY_ALLOW_MUSICBRAINZ_TAGGED_FILES is True
and not serializer.validated_data.get("mbid")
):
check_mbid = preferences.get("music__only_allow_musicbrainz_tagged_files")
if check_mbid is True and not serializer.validated_data.get("mbid"):
return fail_import(
upload,
"Uploading files without a MusicBrainz ID is not permitted in this pod",