diff --git a/api/funkwhale_api/music/filters.py b/api/funkwhale_api/music/filters.py index d8d703407..f9eba868a 100644 --- a/api/funkwhale_api/music/filters.py +++ b/api/funkwhale_api/music/filters.py @@ -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, diff --git a/changes/changelog.d/1053.feature b/changes/changelog.d/1053.feature new file mode 100644 index 000000000..8f4c1b9d4 --- /dev/null +++ b/changes/changelog.d/1053.feature @@ -0,0 +1 @@ +Allow users to hide compilation artists on the artist search page (#1053) \ No newline at end of file diff --git a/docs/api/parameters.yml b/docs/api/parameters.yml index f8345ff86..088716e22 100644 --- a/docs/api/parameters.yml +++ b/docs/api/parameters.yml @@ -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" diff --git a/docs/swagger.yml b/docs/swagger.yml index 6327dde77..6b34c752e 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -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" diff --git a/front/src/components/library/Artists.vue b/front/src/components/library/Artists.vue index 98d06e776..e72228589 100644 --- a/front/src/components/library/Artists.vue +++ b/front/src/components/library/Artists.vue @@ -44,6 +44,13 @@ +