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
9e12fd40
Commit
9e12fd40
authored
1 year ago
by
Konrad Mohrfeldt
Browse files
Options
Downloads
Patches
Plain Diff
feat(REST): add order filter to /shows endpoint
The dashboard must be able to sort shows.
parent
d72df7c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/filters.py
+10
-0
10 additions, 0 deletions
program/filters.py
with
10 additions
and
0 deletions
program/filters.py
+
10
−
0
View file @
9e12fd40
...
@@ -39,6 +39,10 @@ class IntegerInFilter(filters.BaseInFilter):
...
@@ -39,6 +39,10 @@ class IntegerInFilter(filters.BaseInFilter):
class
ShowFilterSet
(
StaticFilterHelpTextMixin
,
filters
.
FilterSet
):
class
ShowFilterSet
(
StaticFilterHelpTextMixin
,
filters
.
FilterSet
):
order
=
filters
.
OrderingFilter
(
fields
=
[
"
name
"
,
"
id
"
,
"
is_active
"
,
"
is_owner
"
],
help_text
=
"
Order shows by the given field(s).
"
,
)
category_ids
=
IntegerInFilter
(
category_ids
=
IntegerInFilter
(
field_name
=
"
category
"
,
field_name
=
"
category
"
,
help_text
=
"
Return only shows of the given category or categories.
"
,
help_text
=
"
Return only shows of the given category or categories.
"
,
...
@@ -96,6 +100,11 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
...
@@ -96,6 +100,11 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
help_text
=
"
Return only shows of the given type slug.
"
,
help_text
=
"
Return only shows of the given type slug.
"
,
)
)
def
filter_queryset
(
self
,
queryset
):
_id
=
getattr
(
self
.
request
.
user
,
"
id
"
,
None
)
queryset
=
queryset
.
annotate
(
is_owner
=
Q
(
owners
=
_id
))
return
super
().
filter_queryset
(
queryset
)
def
filter_active
(
self
,
queryset
:
QuerySet
,
name
:
str
,
value
:
bool
):
def
filter_active
(
self
,
queryset
:
QuerySet
,
name
:
str
,
value
:
bool
):
# Filter currently running shows
# Filter currently running shows
# Get currently running schedules to filter by first
# Get currently running schedules to filter by first
...
@@ -127,6 +136,7 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
...
@@ -127,6 +136,7 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
class
Meta
:
class
Meta
:
model
=
models
.
Show
model
=
models
.
Show
fields
=
[
fields
=
[
"
order
"
,
"
category_ids
"
,
"
category_ids
"
,
"
category_slug
"
,
"
category_slug
"
,
"
host_ids
"
,
"
host_ids
"
,
...
...
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