Skip to content
Extraits de code Groupes Projets
Valider d2564c1e rédigé par luxcem's avatar luxcem
Parcourir les fichiers

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
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 82 ajouts et 26 suppressions
%ul.nav-bar %ul.nav-bar
%li %li
%a{href: "{% url 'representatives:index' %}"} %a{href: "{% url 'legislature:representatives_index' %}"}
Representatives Representatives
Fichier déplacé
Fichier déplacé
Fichier déplacé
- 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
) )
Fichier déplacé
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>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter