Commit 0558edff authored by Nicolas Joyard's avatar Nicolas Joyard

Force representative detail ordering

parent 60164497
......@@ -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="126 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="126 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>
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment