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
TAlone
memopol
Commits
e6df0ee4
Commit
e6df0ee4
authored
Jun 28, 2016
by
Nicolas Joyard
Browse files
Force a specific ordering of entries
parent
4ab9da5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
memopol/views/representative_detail.py
View file @
e6df0ee4
...
...
@@ -59,8 +59,9 @@ class RepresentativeDetail(RepresentativeViewMixin, generic.DetailView):
c
[
'votes'
]
=
c
[
'object'
].
votes
.
all
()
c
[
'mandates'
]
=
c
[
'object'
].
mandates
.
all
()
c
[
'positions'
]
=
c
[
'object'
].
positions
.
filter
(
published
=
True
).
prefetch_related
(
'tags'
)
c
[
'positions'
]
=
c
[
'object'
].
positions
.
filter
(
published
=
True
)
\
.
prefetch_related
(
'tags'
)
\
.
order_by
(
'-datetime'
,
'pk'
)
c
[
'position_form'
]
=
PositionForm
(
initial
=
{
'representative'
:
self
.
object
.
pk
})
...
...
memopol/views/representative_mixin.py
View file @
e6df0ee4
...
...
@@ -20,9 +20,9 @@ class RepresentativeViewMixin(object):
"""
Prefetch Mandates with their Group and Constituency with Country.
"""
mandates
=
Mandate
.
objects
.
order_by
(
'
-end_date'
).
select_related
(
'constituency__country'
,
'group'
,
'group__chamber'
)
mandates
=
Mandate
.
objects
.
order_by
(
'-end_date'
,
'-begin_date'
,
'
group__kind'
,
'group__name'
).
select_related
(
'group'
,
'group__chamber'
,
'constituency__country'
)
return
queryset
.
prefetch_related
(
models
.
Prefetch
(
'mandates'
,
queryset
=
mandates
))
...
...
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