diff --git a/memopol_representatives/templates/memopol_representatives/view.html b/memopol_representatives/templates/memopol_representatives/view.html index 13a8d2416565ac1718f59fc8411d7d7d96f098a8..a9ba5edc595c898e05407374e054f43ac41f271a 100644 --- a/memopol_representatives/templates/memopol_representatives/view.html +++ b/memopol_representatives/templates/memopol_representatives/view.html @@ -10,27 +10,20 @@ <h1>{{ representative.full_name }}</h1> -<p> - {{ representative.country.name }} {{ representative.gender }} <br> - Born in {{ representative.birth_place }} the {{ representative.birth_date }} <br> -</p> +{% for mandate in representative.mandate_set.all %} +{% if mandate.group.kind == "group" %} +<h3>{{ mandate.role }} of {{ mandate.group.name }}</h3> +{% endif %} +{% endfor %} + +<p>Born in {{ representative.birth_place }} the {{ representative.birth_date }} ({{ representative.get_gender_display }})</p> +<p>{{ representative.country.name }}</p> -<h2 style="clear: both">Mandates</h2> +<h2 style="clear: both">Committees</h2> {% for mandate in representative.mandate_set.all %} -<div class="mandate"> - <h3> - {{ mandate.group.name }} - <small> - {{ mandate.role }} - </small> - </h3> - <p> - {{ mandate.begin_date }} to {{ mandate.end_date }} <br> - <strong>{{ mandate.group.kind }}</strong> : <em>{{ mandate.group.name }} ({{ mandate.group.abbreviation }})</em> <br> - Constituency : {{ mandate.constituency.name }} <br> - </p> -</div> -<hr> +{% if mandate.group.kind == "committee" %} + <p>{{ mandate.role }} of {{ mandate.group.name }} ({{ mandate.group.abbreviation }}) +{% endif %} {% endfor %} {% endblock %} diff --git a/memopol_representatives/urls.py b/memopol_representatives/urls.py index 53be2454d1095d3e46037c10b9e62e0ed0cad714..82933f63bb1e48d99d3cbfecd283bd157a079b78 100644 --- a/memopol_representatives/urls.py +++ b/memopol_representatives/urls.py @@ -5,5 +5,6 @@ from memopol_representatives import views urlpatterns = patterns( '', url(r'^$', views.index, name='index'), + url(r'^committee/(?P<committee>\w{4})$', views.committee, name='committee'), url(r'^view/(?P<num>\d+)$', views.view, name='view'), ) diff --git a/memopol_representatives/views.py b/memopol_representatives/views.py index af8a34bf91361bab70ab8e25feacecb6774e7bb8..04e5e9af7490d6d71d08df6c79aadfa09a8f6610 100644 --- a/memopol_representatives/views.py +++ b/memopol_representatives/views.py @@ -19,7 +19,45 @@ def index(request): else: representative_list = Representative.objects.all() - paginator = Paginator(representative_list, 5) + paginator = Paginator(representative_list, 50) + + page = request.GET.get('page') + try: + representatives = paginator.page(page) + except PageNotAnInteger: + representatives = paginator.page(1) + except EmptyPage: + representatives = paginator.page(paginator.num_pages) + + context['representatives'] = representatives + return render( + request, + 'memopol_representatives/list.html', + context + ) + + +def committee(request, committee): + context = {} + if request.GET.get('search'): + search = request.GET.get('search') + representative_list = Representative.objects.filter( + mandate__group__kind='committee', + mandate__group__abbreviation=committee + ).filter( + Q(full_name__icontains=search) + ) + queries_without_page = request.GET.copy() + if 'page' in queries_without_page: + del queries_without_page['page'] + context['queries'] = queries_without_page + else: + representative_list = list(set(Representative.objects.filter( + mandate__group__kind='committee', + mandate__group__abbreviation=committee + ).all())) + + paginator = Paginator(representative_list, 50) page = request.GET.get('page') try: