Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
memopol
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
32
Issues
32
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Political Memory
memopol
Commits
1473e217
Commit
1473e217
authored
Jan 12, 2017
by
okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ok, let's get more readable
parent
4b979839
Pipeline
#746
failed with stage
in 10 minutes
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
src/representatives/filters.py
src/representatives/filters.py
+6
-2
No files found.
src/representatives/filters.py
View file @
1473e217
from
datetime
import
datetime
from
rest_framework.filters
import
BaseFilterBackend
from
rest_framework.filters
import
BaseFilterBackend
from
django.db.models
import
Q
from
django.conf
import
settings
from
.models
import
Mandate
class
ActiveMandateQueryFilterBackend
(
BaseFilterBackend
):
"""
A filter which check if a mandate is active for a reprensentative
...
...
@@ -21,6 +23,8 @@ class ActiveMandateQueryFilterBackend(BaseFilterBackend):
if
self
.
query_param
in
request
.
GET
:
if
len
(
request
.
GET
[
self
.
query_param
]):
qs
=
qs
.
filter
(
mandates__in
=
Mandate
.
objects
.
filter
(
Q
(
end_date__gte
=
datetime
.
today
)
|
Q
(
end_date__isnull
=
True
)).
filter
(
Q
(
group__name
=
request
.
GET
[
self
.
query_param
])
|
Q
(
group__abbreviation
=
request
.
GET
[
self
.
query_param
]))).
distinct
()
qs
=
qs
.
filter
(
mandates__in
=
Mandate
.
objects
.
filter
(
Q
(
end_date__gte
=
datetime
.
today
)
|
Q
(
end_date__isnull
=
True
)).
filter
(
Q
(
group__name
=
request
.
GET
[
self
.
query_param
])
|
Q
(
group__abbreviation
=
request
.
GET
[
self
.
query_param
]))).
distinct
()
return
qs
return
qs
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment