kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Merge branch '548-library-visibility-admin' into 'develop'
Resolve "Admin tools to manage users libraries" Closes #548 See merge request funkwhale/funkwhale!841environments/review-docs-rate-jr6phc/deployments/2479
commit
eed411de7c
|
@ -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)
|
||||
|
|
|
@ -204,6 +204,7 @@ follows_subquery = (
|
|||
class ManageLibraryViewSet(
|
||||
mixins.ListModelMixin,
|
||||
mixins.RetrieveModelMixin,
|
||||
mixins.UpdateModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
viewsets.GenericViewSet,
|
||||
):
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Mods can now change a library visibility through the admin UI (#548)
|
|
@ -96,7 +96,16 @@
|
|||
</router-link>
|
||||
</td>
|
||||
<td>
|
||||
{{ sharedLabels.fields.privacy_level.shortChoices[object.privacy_level] }}
|
||||
<select
|
||||
v-dropdown
|
||||
v-if="object.is_local"
|
||||
@change="updateObj('privacy_level')"
|
||||
v-model="object.privacy_level"
|
||||
|
||||
class="ui search selection dropdown">
|
||||
<option v-for="p in ['me', 'instance', 'everyone']" :value="p">{{ sharedLabels.fields.privacy_level.shortChoices[p] }}</option>
|
||||
</select>
|
||||
<template v-else>{{ sharedLabels.fields.privacy_level.shortChoices[object.privacy_level] }}</template>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -308,7 +317,28 @@ export default {
|
|||
},
|
||||
getQuery (field, value) {
|
||||
return `${field}:"${value}"`
|
||||
}
|
||||
},
|
||||
updateObj(attr, toNull) {
|
||||
let newValue = this.object[attr]
|
||||
if (toNull && !newValue) {
|
||||
newValue = null
|
||||
}
|
||||
let params = {}
|
||||
params[attr] = newValue
|
||||
axios.patch(`manage/library/libraries/${this.id}/`, params).then(
|
||||
response => {
|
||||
logger.default.info(
|
||||
`${attr} was updated succcessfully to ${newValue}`
|
||||
)
|
||||
},
|
||||
error => {
|
||||
logger.default.error(
|
||||
`Error while setting ${attr} to ${newValue}`,
|
||||
error
|
||||
)
|
||||
}
|
||||
)
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
labels() {
|
||||
|
|
Ładowanie…
Reference in New Issue