make setting dynamic
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2607>
This commit is contained in:
parent
d3b27b4ba9
commit
179c53695e
|
@ -1484,10 +1484,3 @@ Typesense hostname. Defaults to `localhost` on non-Docker deployments and to `ty
|
||||||
Docker deployments.
|
Docker deployments.
|
||||||
"""
|
"""
|
||||||
TYPESENSE_NUM_TYPO = env("TYPESENSE_NUM_TYPO", default=5)
|
TYPESENSE_NUM_TYPO = env("TYPESENSE_NUM_TYPO", default=5)
|
||||||
|
|
||||||
ONLY_ALLOW_MUSICBRAINZ_TAGGED_FILES = env(
|
|
||||||
"ONLY_ALLOW_MUSICBRAINZ_TAGGED_FILES", default=False
|
|
||||||
)
|
|
||||||
"""
|
|
||||||
If True, files without a Musicbrainz id will not be uploaded.
|
|
||||||
"""
|
|
||||||
|
|
|
@ -32,3 +32,18 @@ class MusicCacheDuration(types.IntPreference):
|
||||||
"will be erased and retranscoded on the next listening."
|
"will be erased and retranscoded on the next listening."
|
||||||
)
|
)
|
||||||
field_kwargs = {"required": False}
|
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
|
||||||
|
|
|
@ -247,10 +247,8 @@ def process_upload(upload, update_denormalization=True):
|
||||||
return fail_import(
|
return fail_import(
|
||||||
upload, "invalid_metadata", detail=detail, file_metadata=metadata_dump
|
upload, "invalid_metadata", detail=detail, file_metadata=metadata_dump
|
||||||
)
|
)
|
||||||
if (
|
check_mbid = preferences.get("music__only_allow_musicbrainz_tagged_files")
|
||||||
settings.ONLY_ALLOW_MUSICBRAINZ_TAGGED_FILES is True
|
if check_mbid is True and not serializer.validated_data.get("mbid"):
|
||||||
and not serializer.validated_data.get("mbid")
|
|
||||||
):
|
|
||||||
return fail_import(
|
return fail_import(
|
||||||
upload,
|
upload,
|
||||||
"Uploading files without a MusicBrainz ID is not permitted in this pod",
|
"Uploading files without a MusicBrainz ID is not permitted in this pod",
|
||||||
|
|
|
@ -179,7 +179,6 @@ env = [
|
||||||
"DISABLE_PASSWORD_VALIDATORS=false",
|
"DISABLE_PASSWORD_VALIDATORS=false",
|
||||||
"FUNKWHALE_PLUGINS=",
|
"FUNKWHALE_PLUGINS=",
|
||||||
"MUSIC_DIRECTORY_PATH=/music",
|
"MUSIC_DIRECTORY_PATH=/music",
|
||||||
"ONLY_ALLOW_MUSICBRAINZ_TAGGED_FILES=true",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.coverage.run]
|
[tool.coverage.run]
|
||||||
|
|
|
@ -429,8 +429,3 @@ def clear_license_cache(db):
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def faker():
|
def faker():
|
||||||
return factory.Faker._get_faker()
|
return factory.Faker._get_faker()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
|
||||||
def dont_check_mbid(settings):
|
|
||||||
settings.ONLY_ALLOW_MUSICBRAINZ_TAGGED_FILES = False
|
|
||||||
|
|
|
@ -1402,7 +1402,8 @@ def test_fs_import(factories, cache, mocker, settings):
|
||||||
assert "Pruning dangling tracks" in cache.get("fs-import:logs")[-1]
|
assert "Pruning dangling tracks" in cache.get("fs-import:logs")[-1]
|
||||||
|
|
||||||
|
|
||||||
def test_upload_checks_mbid_tag(temp_signal, factories, mocker):
|
def test_upload_checks_mbid_tag(temp_signal, factories, mocker, preferences):
|
||||||
|
preferences["music__only_allow_musicbrainz_tagged_files"] = True
|
||||||
mocker.patch("funkwhale_api.federation.routes.outbox.dispatch")
|
mocker.patch("funkwhale_api.federation.routes.outbox.dispatch")
|
||||||
mocker.patch("funkwhale_api.music.tasks.populate_album_cover")
|
mocker.patch("funkwhale_api.music.tasks.populate_album_cover")
|
||||||
mocker.patch("funkwhale_api.music.metadata.Metadata.get_picture")
|
mocker.patch("funkwhale_api.music.metadata.Metadata.get_picture")
|
||||||
|
|
|
@ -364,7 +364,7 @@ def test_handle_modified_update_existing_path_if_found_and_attributed_to(
|
||||||
update_track_metadata.assert_not_called()
|
update_track_metadata.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
def test_import_files(factories, capsys, dont_check_mbid):
|
def test_import_files(factories, capsys):
|
||||||
# smoke test to ensure the command run properly
|
# smoke test to ensure the command run properly
|
||||||
library = factories["music.Library"](actor__local=True)
|
library = factories["music.Library"](actor__local=True)
|
||||||
call_command(
|
call_command(
|
||||||
|
|
|
@ -57,6 +57,8 @@ const groups = computed(() => [
|
||||||
settings: [
|
settings: [
|
||||||
{ name: 'music__transcoding_enabled' },
|
{ name: 'music__transcoding_enabled' },
|
||||||
{ name: 'music__transcoding_cache_duration' }
|
{ name: 'music__transcoding_cache_duration' }
|
||||||
|
{ name: 'music__only_allow_musicbrainz_tagged_files' },
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue