Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arthur Brugière
funkwhale
Commits
32e7bc8a
Unverified
Commit
32e7bc8a
authored
4 years ago
by
Agate
💬
Browse files
Options
Downloads
Patches
Plain Diff
Exclude external podcasts from library home
parent
fcd1e1b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/funkwhale_api/audio/filters.py
+15
-1
15 additions, 1 deletion
api/funkwhale_api/audio/filters.py
api/tests/audio/test_filters.py
+16
-0
16 additions, 0 deletions
api/tests/audio/test_filters.py
front/src/components/library/Home.vue
+1
-1
1 addition, 1 deletion
front/src/components/library/Home.vue
with
32 additions
and
2 deletions
api/funkwhale_api/audio/filters.py
+
15
−
1
View file @
32e7bc8a
...
...
@@ -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
):
"""
...
...
This diff is collapsed.
Click to expand it.
api/tests/audio/test_filters.py
+
16
−
0
View file @
32e7bc8a
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
]]
This diff is collapsed.
Click to expand it.
front/src/components/library/Home.vue
+
1
−
1
View file @
32e7bc8a
...
...
@@ -30,7 +30,7 @@
<h3
class=
"ui header"
>
<translate
translate-context=
"*/*/*"
>
New channels
</translate>
</h3>
<channels-widget
:show-modification-date=
"true"
:limit=
"12"
:filters=
"
{ordering: '-creation_date'}">
</channels-widget>
<channels-widget
:show-modification-date=
"true"
:limit=
"12"
:filters=
"
{ordering: '-creation_date'
, external: 'false'
}">
</channels-widget>
</
template
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment