Merge branch '1053-allow-hiding-compilation-artists-in-the-artists-tab' into 'develop'

Resolve "Allow hiding compilation artists in the Artists tab"

Closes #1063 and #1053

See merge request funkwhale/funkwhale!1179
This commit is contained in:
Agate 2020-07-27 10:57:11 +02:00
commit 2d31262179
7 changed files with 37 additions and 0 deletions

View File

@ -101,6 +101,7 @@ class ArtistFilter(
q = fields.SearchFilter(search_fields=["name"], fts_search_fields=["body_text"])
playable = filters.BooleanFilter(field_name="_", method="filter_playable")
has_albums = filters.BooleanFilter(field_name="_", method="filter_has_albums")
tag = TAG_FILTER
scope = common_filters.ActorScopeFilter(
actor_field="tracks__uploads__library__actor", distinct=True
@ -130,6 +131,12 @@ class ArtistFilter(
actor = utils.get_actor_from_request(self.request)
return queryset.playable_by(actor, value).distinct()
def filter_has_albums(self, queryset, name, value):
if value is True:
return queryset.filter(albums__isnull=False)
else:
return queryset.filter(albums__isnull=True)
class TrackFilter(
RelatedFilterSet,

View File

@ -0,0 +1 @@
Allow users to hide compilation artists on the artist search page (#1053)

View File

@ -67,6 +67,14 @@ Playable:
schema:
required: false
type: "boolean"
HasAlbums:
name: "has_albums"
in: "query"
default: null
description: "Filter/exclude artists with no associated albums"
schema:
required: false
type: "boolean"
Refresh:
name: "refresh"
in: "query"

View File

@ -361,6 +361,7 @@ paths:
- name
- random
- $ref: "./api/parameters.yml#/Playable"
- $ref: "./api/parameters.yml#/HasAlbums"
- $ref: "./api/parameters.yml#/Library"
- $ref: "./api/parameters.yml#/PageNumber"
- $ref: "./api/parameters.yml#/PageSize"

View File

@ -44,6 +44,13 @@
<option :value="parseInt(50)">50</option>
</select>
</div>
<div class="field">
<label><translate translate-context="Content/Search/Checkbox/Noun">Exclude Compilation Artists</translate></label>
<div id="excludeCompilation" class="ui fitted toggle checkbox">
<input id="exclude-compilation" v-model="excludeCompilation" true-value="true" false-value="null" type="checkbox">
<label></label>
</div>
</div>
</div>
</form>
<div class="ui hidden divider"></div>
@ -116,6 +123,7 @@ export default {
return {
isLoading: true,
result: null,
excludeCompilation: true,
page: parseInt(this.defaultPage),
query: this.defaultQuery,
tags: (this.defaultTags || []).filter((t) => { return t.length > 0 }),
@ -161,6 +169,7 @@ export default {
scope: this.scope,
page: this.page,
page_size: this.paginateBy,
has_albums: this.excludeCompilation,
q: this.query,
ordering: this.getOrderingAsString(),
playable: "true",
@ -195,6 +204,9 @@ export default {
},
"$store.state.moderation.lastUpdate": function () {
this.fetchData()
},
excludeCompilation() {
this.fetchData()
}
}
}

View File

@ -47,6 +47,7 @@ $bottom-player-height: 4rem;
@import "./pages/_admin_account_detail.scss";
@import "./pages/_admin_domain_detail.scss";
@import "./pages/_admin_library.scss";
@import "./pages/_artists.scss";
@import "./pages/_home.scss";
@import "./pages/_library.scss";
@import "./pages/_notifications.scss";

View File

@ -0,0 +1,7 @@
#excludeCompilation {
margin-top: 0.7rem;
}
.ui.multiple.search.dropdown > input.search {
width: auto;
}