From a8ab4eedfc042fb0ecd2d95c7adee9ea4ae73991 Mon Sep 17 00:00:00 2001 From: petitminion Date: Thu, 17 Jun 2021 11:04:01 +0000 Subject: [PATCH] Add recently added radio, part of #1390 --- api/funkwhale_api/radios/radios.py | 10 +++++++++- changes/changelog.d/1390.feature | 1 + front/src/components/library/Radios.vue | 1 + front/src/store/radios.js | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changes/changelog.d/1390.feature diff --git a/api/funkwhale_api/radios/radios.py b/api/funkwhale_api/radios/radios.py index 5f37dc7e4..4f23fb281 100644 --- a/api/funkwhale_api/radios/radios.py +++ b/api/funkwhale_api/radios/radios.py @@ -5,11 +5,12 @@ from django.db import connection from django.db.models import Q from rest_framework import serializers -from funkwhale_api.federation import models as federation_models from funkwhale_api.federation import fields as federation_fields +from funkwhale_api.federation import models as federation_models from funkwhale_api.moderation import filters as moderation_filters from funkwhale_api.music.models import Artist, Library, Track, Upload from funkwhale_api.tags.models import Tag + from . import filters, models from .registries import registry @@ -320,3 +321,10 @@ class LibraryRadio(RelatedObjectRadio): def get_related_object_id_repr(self, obj): return obj.uuid + + +@registry.register(name="recently-added") +class RecentlyAdded(SessionRadio): + def get_queryset(self, **kwargs): + qs = super().get_queryset(**kwargs) + return qs.filter(artist__content_category="music").order_by("-creation_date") diff --git a/changes/changelog.d/1390.feature b/changes/changelog.d/1390.feature new file mode 100644 index 000000000..22516579b --- /dev/null +++ b/changes/changelog.d/1390.feature @@ -0,0 +1 @@ +Implemented awesome recently added radio (part of #1390) diff --git a/front/src/components/library/Radios.vue b/front/src/components/library/Radios.vue index 8fd6142ac..8f2b551ae 100644 --- a/front/src/components/library/Radios.vue +++ b/front/src/components/library/Radios.vue @@ -13,6 +13,7 @@ + diff --git a/front/src/store/radios.js b/front/src/store/radios.js index 9cd48e769..475b2457f 100644 --- a/front/src/store/radios.js +++ b/front/src/store/radios.js @@ -27,6 +27,10 @@ export default { 'less-listened': { name: 'Less listened', description: "Listen to tracks you usually don't. It's time to restore some balance." + }, + 'recently-added': { + name: 'Recently Added', + description: "Newest content on the network. Get some fresh air." } } }