From fdeb5ef8ae46833ed14a75f6981f1beed59751c3 Mon Sep 17 00:00:00 2001 From: Agate Date: Wed, 22 Apr 2020 08:03:59 +0200 Subject: [PATCH 1/5] Fixed 500 error when federation is disabled and application+json is requested --- api/funkwhale_api/common/middleware.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/funkwhale_api/common/middleware.py b/api/funkwhale_api/common/middleware.py index 201cd2ec8..7f82ae20c 100644 --- a/api/funkwhale_api/common/middleware.py +++ b/api/funkwhale_api/common/middleware.py @@ -204,7 +204,8 @@ def get_api_response(request, url): except urls.exceptions.Resolver404: return http.HttpResponseNotFound() response = match.func(request, *match.args, **match.kwargs) - response.render() + if hasattr(response, "render"): + response.render() return response From 677a5dcf62f3703bcd7a5d6c3c335481b14e0e65 Mon Sep 17 00:00:00 2001 From: Agate Date: Wed, 22 Apr 2020 08:05:45 +0200 Subject: [PATCH 2/5] Fixed broken channel save when description is too long --- api/funkwhale_api/audio/serializers.py | 2 -- api/tests/audio/test_serializers.py | 3 --- 2 files changed, 5 deletions(-) diff --git a/api/funkwhale_api/audio/serializers.py b/api/funkwhale_api/audio/serializers.py index 6b9227ded..2d812fcf2 100644 --- a/api/funkwhale_api/audio/serializers.py +++ b/api/funkwhale_api/audio/serializers.py @@ -203,8 +203,6 @@ class ChannelUpdateSerializer(serializers.Serializer): description_obj = common_utils.attach_content( obj.artist, "description", validated_data["description"] ) - if description_obj: - actor_update_fields.append(("summary", description_obj.rendered)) if "name" in validated_data: actor_update_fields.append(("name", validated_data["name"])) diff --git a/api/tests/audio/test_serializers.py b/api/tests/audio/test_serializers.py index 3c29bdf45..0eecba8d9 100644 --- a/api/tests/audio/test_serializers.py +++ b/api/tests/audio/test_serializers.py @@ -184,9 +184,6 @@ def test_channel_serializer_update(factories, mocker): sorted(channel.artist.tagged_items.values_list("tag__name", flat=True)) == data["tags"] ) - assert channel.actor.summary == common_utils.render_html( - data["description"]["text"], "text/markdown" - ) assert channel.artist.description.text == data["description"]["text"] assert channel.artist.description.content_type == "text/markdown" assert channel.actor.name == data["name"] From fcd1e1b724536bbd00eafc4fd6a5c62fe8c5e5e5 Mon Sep 17 00:00:00 2001 From: Agate Date: Wed, 22 Apr 2020 08:16:12 +0200 Subject: [PATCH 3/5] Better placeholders for channels --- api/funkwhale_api/audio/serializers.py | 2 +- front/src/components/audio/ChannelEntries.vue | 11 +++++------ front/src/components/audio/ChannelSeries.vue | 11 +++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/api/funkwhale_api/audio/serializers.py b/api/funkwhale_api/audio/serializers.py index 2d812fcf2..c31cdb69d 100644 --- a/api/funkwhale_api/audio/serializers.py +++ b/api/funkwhale_api/audio/serializers.py @@ -200,7 +200,7 @@ class ChannelUpdateSerializer(serializers.Serializer): obj.save(update_fields=["metadata"]) if "description" in validated_data: - description_obj = common_utils.attach_content( + common_utils.attach_content( obj.artist, "description", validated_data["description"] ) diff --git a/front/src/components/audio/ChannelEntries.vue b/front/src/components/audio/ChannelEntries.vue index af3f27943..23f70cbed 100644 --- a/front/src/components/audio/ChannelEntries.vue +++ b/front/src/components/audio/ChannelEntries.vue @@ -13,12 +13,11 @@ diff --git a/front/src/components/audio/ChannelSeries.vue b/front/src/components/audio/ChannelSeries.vue index 5f9fa99d9..69e735987 100644 --- a/front/src/components/audio/ChannelSeries.vue +++ b/front/src/components/audio/ChannelSeries.vue @@ -18,12 +18,11 @@ From 32e7bc8a9ce69e06bb3aa06d5667d4d41a847c8b Mon Sep 17 00:00:00 2001 From: Agate Date: Wed, 22 Apr 2020 09:17:05 +0200 Subject: [PATCH 4/5] Exclude external podcasts from library home --- api/funkwhale_api/audio/filters.py | 16 +++++++++++++++- api/tests/audio/test_filters.py | 16 ++++++++++++++++ front/src/components/library/Home.vue | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/api/funkwhale_api/audio/filters.py b/api/funkwhale_api/audio/filters.py index 3a8da5ca7..6b1a9e8d9 100644 --- a/api/funkwhale_api/audio/filters.py +++ b/api/funkwhale_api/audio/filters.py @@ -4,6 +4,7 @@ import django_filters from funkwhale_api.common import fields from funkwhale_api.common import filters as common_filters +from funkwhale_api.federation import actors from funkwhale_api.moderation import filters as moderation_filters from . import models @@ -28,6 +29,7 @@ class ChannelFilter(moderation_filters.HiddenContentFilterSet): subscribed = django_filters.BooleanFilter( field_name="_", method="filter_subscribed" ) + external = django_filters.BooleanFilter(field_name="_", method="filter_external") ordering = django_filters.OrderingFilter( # tuple-mapping retains order fields=( @@ -38,7 +40,7 @@ class ChannelFilter(moderation_filters.HiddenContentFilterSet): class Meta: model = models.Channel - fields = ["q", "scope", "tag", "subscribed", "ordering"] + fields = ["q", "scope", "tag", "subscribed", "ordering", "external"] hidden_content_fields_mapping = moderation_filters.USER_FILTER_CONFIG["CHANNEL"] def filter_subscribed(self, queryset, name, value): @@ -56,6 +58,18 @@ class ChannelFilter(moderation_filters.HiddenContentFilterSet): else: return queryset.exclude(query) + def filter_external(self, queryset, name, value): + query = Q( + attributed_to=actors.get_service_actor(), + actor__preferred_username__startswith="rssfeed-", + ) + if value is True: + queryset = queryset.filter(query) + if value is False: + queryset = queryset.exclude(query) + + return queryset + class IncludeChannelsFilterSet(django_filters.FilterSet): """ diff --git a/api/tests/audio/test_filters.py b/api/tests/audio/test_filters.py index c0cb9caa4..d7a0a7980 100644 --- a/api/tests/audio/test_filters.py +++ b/api/tests/audio/test_filters.py @@ -1,3 +1,5 @@ +import pytest + from funkwhale_api.audio import filters from funkwhale_api.audio import models @@ -30,3 +32,17 @@ def test_channel_filter_subscribed_false(factories, mocker, queryset_equal_list) ) assert filterset.qs == [other_channel] + + +@pytest.mark.parametrize("external, expected_index", [("true", 0), ("false", 1)]) +def test_channel_filter_external( + external, expected_index, factories, mocker, queryset_equal_list +): + user = factories["users.User"](with_actor=True) + channels = [factories["audio.Channel"](external=True), factories["audio.Channel"]()] + qs = models.Channel.objects.all() + filterset = filters.ChannelFilter( + {"external": external}, request=mocker.Mock(user=user), queryset=qs + ) + + assert filterset.qs == [channels[expected_index]] diff --git a/front/src/components/library/Home.vue b/front/src/components/library/Home.vue index 15f505f84..20df9429a 100644 --- a/front/src/components/library/Home.vue +++ b/front/src/components/library/Home.vue @@ -30,7 +30,7 @@

New channels

- + From 5913baeb57d42b0203b70caf3ff57fb315bdc96a Mon Sep 17 00:00:00 2001 From: Agate Date: Wed, 22 Apr 2020 09:58:20 +0200 Subject: [PATCH 5/5] Fix #1079: fixed another z-index issue with dropdowns --- front/src/components/Sidebar.vue | 2 +- front/src/views/auth/ProfileBase.vue | 2 +- front/src/views/library/DetailBase.vue | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue index 920367433..ea8dc16d8 100644 --- a/front/src/components/Sidebar.vue +++ b/front/src/components/Sidebar.vue @@ -352,7 +352,7 @@ $sidebar-color: #2D2F33; .sidebar { background: $sidebar-color; - z-index: auto; + z-index: 1; @include media(">desktop") { display: flex; flex-direction: column; diff --git a/front/src/views/auth/ProfileBase.vue b/front/src/views/auth/ProfileBase.vue index ac828288b..80ec6ad7d 100644 --- a/front/src/views/auth/ProfileBase.vue +++ b/front/src/views/auth/ProfileBase.vue @@ -6,7 +6,7 @@
-