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