diff --git a/api/funkwhale_api/manage/serializers.py b/api/funkwhale_api/manage/serializers.py index 3ea390b87..8d4b01b05 100644 --- a/api/funkwhale_api/manage/serializers.py +++ b/api/funkwhale_api/manage/serializers.py @@ -519,6 +519,15 @@ class ManageLibrarySerializer(serializers.ModelSerializer): "followers_url", "actor", ] + read_only_fields = [ + "fid", + "uuid", + "id", + "url", + "domain", + "actor", + "creation_date", + ] def get_uploads_count(self, obj): return getattr(obj, "_uploads_count", obj.uploads_count) diff --git a/api/funkwhale_api/manage/views.py b/api/funkwhale_api/manage/views.py index ab6c0c9f2..ea3c33f80 100644 --- a/api/funkwhale_api/manage/views.py +++ b/api/funkwhale_api/manage/views.py @@ -204,6 +204,7 @@ follows_subquery = ( class ManageLibraryViewSet( mixins.ListModelMixin, mixins.RetrieveModelMixin, + mixins.UpdateModelMixin, mixins.DestroyModelMixin, viewsets.GenericViewSet, ): diff --git a/api/tests/manage/test_views.py b/api/tests/manage/test_views.py index 710722b90..a164e4012 100644 --- a/api/tests/manage/test_views.py +++ b/api/tests/manage/test_views.py @@ -322,6 +322,18 @@ def test_library_detail(factories, superuser_api_client): assert response.data["id"] == library.id +def test_library_update(factories, superuser_api_client): + library = factories["music.Library"](privacy_level="public") + url = reverse( + "api:v1:manage:library:libraries-detail", kwargs={"uuid": library.uuid} + ) + response = superuser_api_client.patch(url, {"privacy_level": "me"}) + + assert response.status_code == 200 + library.refresh_from_db() + assert library.privacy_level == "me" + + def test_library_detail_stats(factories, superuser_api_client): library = factories["music.Library"]() url = reverse( diff --git a/changes/changelog.d/548.enhancement b/changes/changelog.d/548.enhancement new file mode 100644 index 000000000..99cd04941 --- /dev/null +++ b/changes/changelog.d/548.enhancement @@ -0,0 +1 @@ +Mods can now change a library visibility through the admin UI (#548) diff --git a/front/src/views/admin/library/LibraryDetail.vue b/front/src/views/admin/library/LibraryDetail.vue index beec7e2b4..db53bd2b5 100644 --- a/front/src/views/admin/library/LibraryDetail.vue +++ b/front/src/views/admin/library/LibraryDetail.vue @@ -96,7 +96,16 @@