Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
AURA
steering
Commits
edaba2e5
Commit
edaba2e5
authored
2 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
Document new filters for Show viewset
parent
7e34a4c2
No related branches found
No related tags found
No related merge requests found
Pipeline
#2509
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/filters.py
+14
-6
14 additions, 6 deletions
program/filters.py
with
14 additions
and
6 deletions
program/filters.py
+
14
−
6
View file @
edaba2e5
...
...
@@ -55,6 +55,9 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
field_name
=
"
music_focus
"
,
help_text
=
"
Return only shows with given music focus(es).
"
,
)
music_focus__slug
=
filters
.
CharFilter
(
field_name
=
"
music_focus
"
,
help_text
=
"
Return only shows with the give music focus slug.
"
)
owner
=
IntegerInFilter
(
field_name
=
"
owners
"
,
help_text
=
"
Return only shows that belong to the given owner(s).
"
,
...
...
@@ -62,15 +65,24 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
category
=
IntegerInFilter
(
help_text
=
"
Return only shows of the given category or categories.
"
,
)
category__slug
=
filters
.
CharFilter
(
field_name
=
"
category
"
,
help_text
=
"
Return only shows of the given category slug.
"
)
language
=
IntegerInFilter
(
help_text
=
"
Return only shows of the given language(s).
"
,
)
topic
=
IntegerInFilter
(
help_text
=
"
Return only shows of the given topic(s).
"
,
)
topic__slug
=
filters
.
CharFilter
(
field_name
=
"
topic
"
,
help_text
=
"
Return only shows of the given topic slug.
"
)
type
=
IntegerInFilter
(
help_text
=
"
Return only shows of a given type.
"
,
)
type__slug
=
filters
.
CharFilter
(
field_name
=
"
type
"
,
help_text
=
"
Return only shows of the given type slug.
"
)
public
=
filters
.
BooleanFilter
(
field_name
=
"
is_public
"
,
help_text
=
"
Return only shows that are public/non-public.
"
,
...
...
@@ -154,9 +166,7 @@ class TimeSlotFilterSet(filters.FilterSet):
),
)
def
filter_surrounding
(
self
,
queryset
:
QuerySet
,
name
:
str
,
value
:
datetime
.
datetime
):
def
filter_surrounding
(
self
,
queryset
:
QuerySet
,
name
:
str
,
value
:
datetime
.
datetime
):
nearest_timeslots_in_future
=
(
models
.
TimeSlot
.
objects
.
filter
(
start__gte
=
value
)
.
order_by
(
"
start
"
)
...
...
@@ -167,9 +177,7 @@ class TimeSlotFilterSet(filters.FilterSet):
.
order_by
(
"
-start
"
)
.
values_list
(
"
id
"
,
flat
=
True
)[:
5
]
)
relevant_timeslot_ids
=
list
(
nearest_timeslots_in_future
)
+
list
(
nearest_timeslots_in_past
)
relevant_timeslot_ids
=
list
(
nearest_timeslots_in_future
)
+
list
(
nearest_timeslots_in_past
)
return
queryset
.
filter
(
id__in
=
relevant_timeslot_ids
)
def
filter_start
(
self
,
queryset
:
QuerySet
,
name
:
str
,
value
:
datetime
.
date
):
...
...
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