Skip to content
Extraits de code Groupes Projets
Valider 2c1afc9b rédigé par Nicolas Joyard's avatar Nicolas Joyard
Parcourir les fichiers

Redirect group URLs to filtered representative list

parent 6f0867e6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -10,7 +10,7 @@ from views.group_ac import GroupAutocomplete
from views.group_list import GroupList
from views.representative_detail import RepresentativeDetail
from views.representative_list import RepresentativeList
from views.redirects import RedirectGroupList
from views.redirects import RedirectGroupList, RedirectGroupRepresentativeList
import api
......@@ -21,12 +21,12 @@ urlpatterns = [
url(
r'^legislature/representative/(?P<group_kind>\w+)/(?P<chamber>.+)/' +
r'(?P<group>.+)/$',
RepresentativeList.as_view(),
RedirectGroupRepresentativeList.as_view(),
name='representative-list'
),
url(
r'^legislature/representative/(?P<group_kind>\w+)/(?P<group>.+)/$',
RepresentativeList.as_view(),
RedirectGroupRepresentativeList.as_view(),
name='representative-list'
),
url(
......
# coding: utf-8
from django.core.urlresolvers import reverse
from django.views.generic.base import RedirectView
from representatives.models import Group
class RedirectGroupList(RedirectView):
permanent = True
query_string = True
pattern_name = 'group-list'
class RedirectGroupRepresentativeList(RedirectView):
permanent = True
def get_redirect_url(self, *args, **kwargs):
if kwargs['group_kind'] == 'chamber':
chamber = Group.objects.get(kind='chamber', name=kwargs['group'])
return '%s?chamber=%s' % (reverse('representative-list'),
chamber.pk)
elif kwargs['group_kind'] == 'country':
country = Group.objects.get(kind='country', name=kwargs['group'])
return '%s?country=%s' % (reverse('representative-list'),
country.pk)
else:
group = Group.objects.get(kind=kwargs['group_kind'],
name=kwargs['group'])
return '%s?group=%s' % (reverse('representative-list'), group.pk)
......@@ -3,13 +3,9 @@
from core.views import GridListMixin, PaginationMixin, CSVDownloadMixin, \
ActiveLegislatureMixin
import datetime
from django.db import models
from django.utils.text import slugify
from django.views import generic
from representatives.models import Group, Representative
from representatives.models import Representative
from ..filters import RepresentativeFilter
from .representative_mixin import RepresentativeViewMixin
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter