kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Fix #548: Mods can now change a library visibility through the admin UI
rodzic
c885c10be1
commit
4d0fedab1f
|
@ -500,6 +500,15 @@ class ManageLibrarySerializer(serializers.ModelSerializer):
|
||||||
"followers_url",
|
"followers_url",
|
||||||
"actor",
|
"actor",
|
||||||
]
|
]
|
||||||
|
read_only_fields = [
|
||||||
|
"fid",
|
||||||
|
"uuid",
|
||||||
|
"id",
|
||||||
|
"url",
|
||||||
|
"domain",
|
||||||
|
"actor",
|
||||||
|
"creation_date",
|
||||||
|
]
|
||||||
|
|
||||||
def get_uploads_count(self, obj):
|
def get_uploads_count(self, obj):
|
||||||
return getattr(obj, "_uploads_count", obj.uploads_count)
|
return getattr(obj, "_uploads_count", obj.uploads_count)
|
||||||
|
|
|
@ -200,6 +200,7 @@ follows_subquery = (
|
||||||
class ManageLibraryViewSet(
|
class ManageLibraryViewSet(
|
||||||
mixins.ListModelMixin,
|
mixins.ListModelMixin,
|
||||||
mixins.RetrieveModelMixin,
|
mixins.RetrieveModelMixin,
|
||||||
|
mixins.UpdateModelMixin,
|
||||||
mixins.DestroyModelMixin,
|
mixins.DestroyModelMixin,
|
||||||
viewsets.GenericViewSet,
|
viewsets.GenericViewSet,
|
||||||
):
|
):
|
||||||
|
|
|
@ -322,6 +322,18 @@ def test_library_detail(factories, superuser_api_client):
|
||||||
assert response.data["id"] == library.id
|
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):
|
def test_library_detail_stats(factories, superuser_api_client):
|
||||||
library = factories["music.Library"]()
|
library = factories["music.Library"]()
|
||||||
url = reverse(
|
url = reverse(
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Mods can now change a library visibility through the admin UI (#548)
|
|
@ -96,7 +96,16 @@
|
||||||
</router-link>
|
</router-link>
|
||||||
</td>
|
</td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -308,7 +317,28 @@ export default {
|
||||||
},
|
},
|
||||||
getQuery (field, value) {
|
getQuery (field, value) {
|
||||||
return `${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: {
|
computed: {
|
||||||
labels() {
|
labels() {
|
||||||
|
|
Ładowanie…
Reference in New Issue