From a9d59b66d8561fd32297dd13b5c1ae26b15e0025 Mon Sep 17 00:00:00 2001 From: jpic <jamespic@gmail.com> Date: Sat, 19 Dec 2015 13:34:42 +0100 Subject: [PATCH] Remove pk support in mep url --- legislature/urls.py | 6 ------ legislature/views/representative.py | 22 +++++++--------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/legislature/urls.py b/legislature/urls.py index e85a64a7..ba80ceb1 100644 --- a/legislature/urls.py +++ b/legislature/urls.py @@ -35,12 +35,6 @@ urlpatterns = [ representative.detail, name='representative-detail' ), - # Representative detail by representative pk - url( - r'^(?P<pk>\d+)$', - representative.detail, - name='representative-detail' - ), # List of representatives by group kind and group name or pk url( r'^(?P<group_kind>\w+)/(?P<group>.+)$', diff --git a/legislature/views/representative.py b/legislature/views/representative.py index a2408597..b59a8e36 100644 --- a/legislature/views/representative.py +++ b/legislature/views/representative.py @@ -82,22 +82,14 @@ def index(request, group_kind=None, group=None): ) -def detail(request, pk=None, name=None): +def detail(request, name=None): + query_set = MemopolRepresentative.objects.select_related( + 'country', + 'main_mandate' + ) + try: - query_set = MemopolRepresentative.objects.select_related( - 'country', - 'main_mandate' - ) - if pk: - representative = query_set.get( - id=pk - ) - elif name: - representative = query_set.get( - slug=name - ) - else: - return Http404() + representative = query_set.get(slug=name) except MemopolRepresentative.DoesNotExist: return Http404() -- GitLab