Skip to content
GitLab
Menu
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
0558edff
Commit
0558edff
authored
Oct 06, 2016
by
Nicolas Joyard
Browse files
Force representative detail ordering
parent
60164497
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/memopol/tests/response_fixtures/RepresentativeDetailTest.test_details.content
View file @
0558edff
...
...
@@ -58,16 +58,16 @@
<span class="label label-primary" data-placement="bottom" data-toggle="tooltip" title="1 Rue
Sadi Carnot – Annonay 07100
, France">
<span class="label label-primary" data-placement="bottom" data-toggle="tooltip" title="1
26
Rue
de l'Université – Paris 75355
, France">
<i class="fa fa-envelope" title=""></i>
Other address
Assemblée nationale
</span>
<span class="label label-primary" data-placement="bottom" data-toggle="tooltip" title="1
26
Rue
de l'Université – Paris 75355
, France">
<span class="label label-primary" data-placement="bottom" data-toggle="tooltip" title="1 Rue
Sadi Carnot – Annonay 07100
, France">
<i class="fa fa-envelope" title=""></i>
Assemblée nationale
Other address
</span>
...
...
src/memopol/views/representative_detail_base.py
View file @
0558edff
...
...
@@ -3,7 +3,8 @@
from
django.db
import
models
from
django.views
import
generic
from
representatives.models
import
Chamber
,
Representative
,
Phone
,
WebSite
from
representatives.models
import
(
Address
,
Chamber
,
Representative
,
Phone
,
WebSite
)
from
.representative_mixin
import
RepresentativeViewMixin
...
...
@@ -30,22 +31,29 @@ class RepresentativeDetailBase(RepresentativeViewMixin, PositionFormMixin,
'email_set'
,
models
.
Prefetch
(
'website_set'
,
queryset
=
WebSite
.
objects
.
filter
(
kind__in
=
social
),
queryset
=
WebSite
.
objects
.
filter
(
kind__in
=
social
)
.
order_by
(
'id'
),
to_attr
=
'social_websites'
),
models
.
Prefetch
(
'website_set'
,
queryset
=
WebSite
.
objects
.
filter
(
kind__in
=
chambers
),
queryset
=
WebSite
.
objects
.
filter
(
kind__in
=
chambers
)
.
order_by
(
'id'
),
to_attr
=
'chamber_websites'
),
models
.
Prefetch
(
'website_set'
,
queryset
=
WebSite
.
objects
.
exclude
(
kind__in
=
social
)
.
exclude
(
kind__in
=
chambers
),
.
exclude
(
kind__in
=
chambers
)
.
order_by
(
'id'
),
to_attr
=
'other_websites'
),
'address_set__country'
,
'address_set__phones'
,
models
.
Prefetch
(
'address_set'
,
queryset
=
Address
.
objects
.
select_related
(
'country'
)
.
prefetch_related
(
'phones'
)
.
order_by
(
'id'
)
),
models
.
Prefetch
(
'phone_set'
,
queryset
=
Phone
.
objects
.
filter
(
address__isnull
=
True
)
...
...
Write
Preview
Supports
Markdown
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