Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Political Memory
memopol
Commits
7cd9b63b
Commit
7cd9b63b
authored
Jun 09, 2016
by
Nicolas Joyard
Browse files
Use last mandate as main_mandate even when finished
parent
5457ba81
Changes
1
Hide whitespace changes
Inline
Side-by-side
memopol/views/representative_mixin.py
View file @
7cd9b63b
# coding: utf-8
# coding: utf-8
import
datetime
from
django.db
import
models
from
django.db
import
models
from
representatives.models
import
Mandate
from
representatives.models
import
Mandate
...
@@ -35,7 +33,6 @@ class RepresentativeViewMixin(object):
...
@@ -35,7 +33,6 @@ class RepresentativeViewMixin(object):
Note that this will butcher your database if you don't use
Note that this will butcher your database if you don't use
self.prefetch_related.
self.prefetch_related.
"""
"""
today
=
datetime
.
date
.
today
()
representative
.
country
=
None
representative
.
country
=
None
representative
.
main_mandate
=
None
representative
.
main_mandate
=
None
...
@@ -44,8 +41,7 @@ class RepresentativeViewMixin(object):
...
@@ -44,8 +41,7 @@ class RepresentativeViewMixin(object):
if
m
.
constituency
.
country_id
and
not
representative
.
country
:
if
m
.
constituency
.
country_id
and
not
representative
.
country
:
representative
.
country
=
m
.
constituency
.
country
representative
.
country
=
m
.
constituency
.
country
if
((
m
.
end_date
is
None
or
m
.
end_date
>
today
)
and
if
(
m
.
group
.
kind
==
'group'
and
m
.
group
.
kind
==
'group'
and
not
representative
.
main_mandate
):
not
representative
.
main_mandate
):
representative
.
main_mandate
=
m
representative
.
main_mandate
=
m
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment