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

Force representative detail ordering

parent 60164497
...@@ -58,16 +58,16 @@ ...@@ -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> <i class="fa fa-envelope" title=""></i>
Other address Assemblée nationale
</span> </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> <i class="fa fa-envelope" title=""></i>
Assemblée nationale Other address
</span> </span>
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
from django.db import models from django.db import models
from django.views import generic 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 from .representative_mixin import RepresentativeViewMixin
...@@ -30,22 +31,29 @@ class RepresentativeDetailBase(RepresentativeViewMixin, PositionFormMixin, ...@@ -30,22 +31,29 @@ class RepresentativeDetailBase(RepresentativeViewMixin, PositionFormMixin,
'email_set', 'email_set',
models.Prefetch( models.Prefetch(
'website_set', 'website_set',
queryset=WebSite.objects.filter(kind__in=social), queryset=WebSite.objects.filter(kind__in=social)
.order_by('id'),
to_attr='social_websites' to_attr='social_websites'
), ),
models.Prefetch( models.Prefetch(
'website_set', 'website_set',
queryset=WebSite.objects.filter(kind__in=chambers), queryset=WebSite.objects.filter(kind__in=chambers)
.order_by('id'),
to_attr='chamber_websites' to_attr='chamber_websites'
), ),
models.Prefetch( models.Prefetch(
'website_set', 'website_set',
queryset=WebSite.objects.exclude(kind__in=social) queryset=WebSite.objects.exclude(kind__in=social)
.exclude(kind__in=chambers), .exclude(kind__in=chambers)
.order_by('id'),
to_attr='other_websites' to_attr='other_websites'
), ),
'address_set__country', models.Prefetch(
'address_set__phones', 'address_set',
queryset=Address.objects.select_related('country')
.prefetch_related('phones')
.order_by('id')
),
models.Prefetch( models.Prefetch(
'phone_set', 'phone_set',
queryset=Phone.objects.filter(address__isnull=True) queryset=Phone.objects.filter(address__isnull=True)
......
Supports Markdown
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