Commit 33c28b26 authored by Mindiell's avatar Mindiell

Added a 'committee' view and modified MEP view

parent 05ab274e
......@@ -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 %}
......@@ -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'),
)
......@@ -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:
......
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