Commit d2564c1e authored by luxcem's avatar luxcem

renames app "memopol_representatives" to "legislature", this app handle...

renames app "memopol_representatives" to "legislature", this app handle representatives, committee, groups, mandates etc, unified urls
parent 22fa8be1
%ul.nav-bar
%li
%a{href: "{% url 'representatives:index' %}"}
%a{href: "{% url 'legislature:representatives_index' %}"}
Representatives
- extends 'base.html'
- block content
- for group in groups
{{ group.name }}
%br
%td<
%a{'href': "{% url 'representatives.detail' ={representative.id} %}"}
%a{'href': "{% url 'legislature:representative_view_by_name' representative.full_name %}"}
%img{'src':'={representative.photo}'}/
%td<
%a{'href': "{% url 'representatives.detail' ={representative.id} %}"}
%a{'href': "{% url 'legislature:representative_view_by_name' representative.full_name %}"}
={representative.full_name} [={representative.country.code}]
%td<
- for mandate in representative.mandate_set.all
={mandate.group.name}
%br/a
......@@ -3,8 +3,6 @@
{% block content %}
<a href="{% url 'representatives:index' %}">Back</a>
<p style="float: left">
<img src="{{ representative.photo }}">
</p>
......
- extends "base.html"
- block content
- include 'memopol_representatives/search.html'
- include 'legislature/search.html'
%p
Number of representatives: {{ representative_num }}
......@@ -9,7 +9,7 @@
%table
- for representative in representatives
%tr
- include 'memopol_representatives/representative_block.html'
- include 'legislature/representative_block.html'
.pagination
%span.step-links
......
......@@ -14,6 +14,6 @@ def by_mandate_url(mandate):
kwargs['search'] = mandate.group.name
return reverse(
'representatives:list',
'legislature:representatives_by_mandate',
kwargs=kwargs
)
from django.conf.urls import patterns, url
from . import views
urlpatterns = patterns(
'',
url(
r'^representatives/?$',
views.representatives_index,
name='representatives_index'
),
url(
r'^representatives/view/(?P<num>\d+)$',
views.representative_view,
name='representative_view'
),
url(
r'^representatives/(?P<mandate_kind>\w+)/(?P<search>.+)$',
views.representatives_by_mandate,
name='representatives_by_mandate'
),
url(
r'^representatives/(?P<name>.+)$',
views.representative_by_name,
name='representative_view_by_name'
),
url(
r'^group/(?P<kind>\w+)$',
views.group_by_kind,
name='group_by_kind'
)
)
......@@ -2,10 +2,10 @@ from django.shortcuts import render, get_object_or_404
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import Q
from representatives.models import Representative
from representatives.models import Representative, Group
def index(request):
def representatives_index(request):
representative_list = _filter_by_search(
request,
Representative.objects.all()
......@@ -14,7 +14,28 @@ def index(request):
return _render_list(request, representative_list)
def by_mandate(request, mandate_kind, mandate_abbr=None, mandate_name=None, search=None):
def representative_by_name(request, name):
representative = get_object_or_404(
Representative, full_name=name)
return render(
request,
'legislature/representative_view.html',
{'representative': representative}
)
def representative_view(request, num):
representative = get_object_or_404(Representative, pk=num)
return render(
request,
'legislature/representative_view.html',
{'representative': representative}
)
def representatives_by_mandate(request, mandate_kind, mandate_abbr=None,
mandate_name=None, search=None):
if mandate_abbr:
representative_list = Representative.objects.filter(
mandate__group__abbreviation=mandate_abbr,
......@@ -82,16 +103,18 @@ def _render_list(request, representative_list, num_by_page=50):
context['representative_num'] = paginator.count
return render(
request,
'memopol_representatives/list.html',
'legislature/representatives_list.html',
context
)
def view(request, num):
representative = get_object_or_404(Representative, pk=num)
def group_by_kind(request, kind):
groups = Group.objects.filter(
kind=kind
)
return render(
request,
'memopol_representatives/view.html',
{'representative': representative}
'legislature/group_list.html',
{'groups': groups}
)
......@@ -6,7 +6,7 @@ import core.views
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'memopol.views.home', name='home'),
url(r'^representatives/', include('memopol_representatives.urls', namespace='representatives')),
url(r'^$', core.views.HomeView.as_view(), name='index'),
url('', include('legislature.urls', namespace='legislature')),
url(r'^admin/', include(admin.site.urls)),
)
<td>
<a href="{% url 'representatives:view' representative.id %}">
<img src="{{ representative.photo }}" />
</a>
</td>
<td>
<a href="{% url 'representatives:view' representative.id %}">
{{ representative.full_name }}&nbsp;[{{ representative.country.code }}]
</a>
</td>
from django.conf.urls import patterns, include, url
from memopol_representatives import views
urlpatterns = patterns(
'',
url(r'^$', views.index, name='index'),
url(r'^l/(?P<mandate_kind>\w+)/(?P<search>.+)$',
views.by_mandate, name='list'),
url(r'^view/(?P<num>\d+)$', views.view, name='view'),
)
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