Skip to content
Extraits de code Groupes Projets
Valider e571ce4c rédigé par Arnaud Fabre's avatar Arnaud Fabre
Parcourir les fichiers

Improvement of representatives pages

parent 27d3dfe5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
- load representatives_extras
- load humanize
.representative
......@@ -30,4 +31,5 @@
%th Biography
%td
Born in {{ representative.birth_place }} the
{{ representative.birth_date }} ({{ representative.get_gender_display }})
{{ representative.birth_date|naturalday:'d/m/Y' }}
({{ representative.get_gender_display }})
-# List representatives' groups
- extends 'base.html'
- load by_group_url
- load representatives_extras
- block content
%table.table
......
......@@ -46,8 +46,8 @@
%td
%a{:href => "{{ mandate|by_group_url }}"}
{{ mandate.group.name }} ({{ mandate.group.abbreviation }})
%td= mandate.begin_date
%td= mandate.end_date
%td= mandate.begin_date|mandate_date:'d/m/Y'
%td= mandate.end_date|mandate_date:'d/m/Y'
%td= mandate.constituency.name
.positions
......@@ -56,7 +56,7 @@
%table.table.table-condensed
- for position in representative.positions.published.all
%tr.position
%td= position.datetime|naturalday:"d/m/Y"
%td= position.datetime|naturalday:'d/m/Y'
%td
%a{:href => '{% url "positions:position-detail" position.pk %}'}
=position.text|truncatewords:8
......
from django import template
from django.core.urlresolvers import reverse
from representatives.models import Mandate, Group
register = template.Library()
@register.filter
def by_group_url(group):
if isinstance(group, Mandate):
group = group.group
if not isinstance(group, Group):
return ''
kwargs = {'group_kind': group.kind}
if group.abbreviation:
kwargs['group'] = group.abbreviation
else:
kwargs['group'] = group.name
# kwargs['group_id'] = group.id
return reverse(
'legislature:representative-index',
kwargs=kwargs
)
# coding: utf-8
# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
"""
This file contains all templatetags used by the representative app
"""
from django import template
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.contrib.humanize.templatetags.humanize import naturalday
from representatives.models import Mandate, Group
register = template.Library()
@register.filter
def mandate_date(date, arg=None):
if date.year == 9999:
return 'present'
else:
return naturalday(date, arg)
@register.filter
def position_icon(position):
if position == 'for':
......@@ -43,9 +76,9 @@ def score_label(score):
@register.filter
def country_flag(country):
return mark_safe('{} <span class="flag-icon flag-icon-{}"></span>'.format(
country.name,
country.code.lower()
return mark_safe('<span class="flag-icon flag-icon-{code}"></span> {name}'.format(
name=country.name,
code=country.code.lower()
))
......
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