Commit 6afccb2f authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Add address, phone, mail badges + rework photo display

parent 6144b356
......@@ -41,9 +41,11 @@ class RepresentativeBaseTest(BaseTest):
- 1 for chamber websites
- 1 for other websites
- 1 for addresses
- 1 for phone numbers
- 1 for address country
- 1 for phone numbers related to addresses
- 1 for other phone numbers
"""
queries = BaseTest.left_pane_queries + 9
queries = BaseTest.left_pane_queries + 11
@property
def url(self):
......
......@@ -3,40 +3,69 @@
</dd>
---
<dd>
<span class="flag-icon flag-icon-fr"></span>
<span class="flag-icon flag-icon-fr"></span> France
</dd>
---
<dd>
<a href="">
membre of Socialiste, écologiste et républicain</a>
 (SER)
</dd>
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-an.png)"></span> Assemblée nationale
</dd>
---
<dd>Born in Annonay (Ardèche) the 16/08/1978 (M)
<dd>
<span class="group-icon" style="background-image: url(/static/collected/images/group-an-ser.png)"></span> Socialiste, écologiste et républicain
(SER)
</dd>
---
<dd>Born on 16/08/1978 in Annonay (Ardèche)
</dd>
---
<dd>
<a class="label label-primary" href="http://twitter.com/olivierdussopt" target="_blank">
<img class="social-icon" src="/static/collected/images/social-twitter.png"/>
<a class="label label-primary" href="http://twitter.com/olivierdussopt" target="_blank">
<img class="social-icon" src="/static/collected/images/social-twitter.png"/>
Twitter
</a>
<a class="label label-primary" href="http://www2.assemblee-nationale.fr/deputes/fiche/OMC_PA330357" target="_blank">
<span class="glyphicon glyphicon-user"></span>
Parliament page
</a>
<a class="label label-primary" href="http://www.olivierdussopt.fr" target="_blank">
<span class="glyphicon glyphicon-link"></span>
Website
</a>
<a class="label label-primary" href="mailto:odussopt@assemblee-nationale.fr">
<b>@</b>
E-mail
</a>
</dd>
---
<dd>
<span class="label label-primary" data-placement="bottom" data-toggle="tooltip" title="1 Rue Sadi Carnot – Annonay 07100, France">
<span class="glyphicon glyphicon-envelope"></span>
Other address
</span>
Twitter
<span class="label label-primary" data-placement="bottom" data-toggle="tooltip" title="126 Rue de l'Université – Paris 75355, France">
<span class="glyphicon glyphicon-envelope"></span>
Assemblée nationale
</span>
</a>
<a class="label label-primary" href="http://www2.assemblee-nationale.fr/deputes/fiche/OMC_PA330357" target="_blank">
<span class="glyphicon glyphicon-user"></span>
Parliament page
</a>
<a class="label label-primary" href="http://www.olivierdussopt.fr" target="_blank">
<span class="glyphicon glyphicon-link"></span>
Website
</a>
</dd>
\ No newline at end of file
</dd>
\ No newline at end of file
<img id="representative-photo" src="http://www.nosdeputes.fr/depute/photo/olivier-dussopt"/>
\ No newline at end of file
<div class="col-sm-3" id="representative-photo" style="background-image:url(http://www.nosdeputes.fr/depute/photo/olivier-dussopt);">
</div>
\ No newline at end of file
......@@ -3,8 +3,7 @@
from django.db import models
from django.views import generic
from representatives.models import Chamber, Representative, Address, Phone, \
WebSite
from representatives.models import Chamber, Representative, Phone, WebSite
from .representative_mixin import RepresentativeViewMixin
......@@ -43,13 +42,11 @@ class RepresentativeDetailBase(RepresentativeViewMixin, PositionFormMixin,
.exclude(kind__in=chambers),
to_attr='other_websites'
),
models.Prefetch(
'address_set',
queryset=Address.objects.select_related('country')
),
'address_set__country',
'address_set__phones',
models.Prefetch(
'phone_set',
queryset=Phone.objects.select_related('address__country')
queryset=Phone.objects.filter(address__isnull=True)
)
)
......
......@@ -72,10 +72,8 @@ h3 {
.label {
font-weight: 400;
}
.label + .label {
margin-left: .25em;
display: inline-block;
line-height: 1.5em;
}
a.custom-invisible, a.custom-invisible:hover, a.custom-invisible:focus {
......@@ -260,6 +258,19 @@ a:hover .custom-thumbnail-details {
MEPs
***************************************************************/
#representative-detail {
display: flex;
flex-flow: row nowrap;
align-items: stretch;
}
#representative-photo {
margin: 15px;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
}
.dl-horizontal dt {
width: 100px;
}
......@@ -372,7 +383,7 @@ iframe {
}
.panel.panel-default .badge {
background-color: #487ED6;
background-color: #487ED6
}
......
......@@ -12,11 +12,10 @@
{% block content %}
<div class="row" id="representative-detail">
<div class="col-sm-3">
<img id="representative-photo" src="{{ representative.photo }}">
<div class="col-sm-3" id="representative-photo" style="background-image:url({{ representative.photo }});">
</div>
<div class="col-sm-9">
<div class="col-sm-9" id="representative-info">
<h1 class="text-center">{{ representative.full_name }}</h1>
<div class="col-sm-9">
......@@ -28,46 +27,90 @@
<dt>{% trans "Country" %}</dt>
<dd>
{{ representative.country|country_flag }}
{{ representative.country|country_flag }} {{ representative.country.name }}
</dd>
<dt>{% trans "Party" %}</dt>
<dd>
{% with mandate=representative.main_mandate %}
<a href="{{ mandate.group.get_absolute_url }}">
{% blocktrans with role=representative.main_mandate.role group_name=mandate.group.name %}
{{ role }} of {{ group_name }}{% endblocktrans %}</a>
{% if mandate.group.abbreviation %}&nbsp;({{ mandate.group.abbreviation }}){% endif %}
{% endwith %}
</dd>
{% with mandate=representative.main_mandate %}
<dt>{% trans "Chamber" %}</dt>
<dd>
{{ mandate.group.chamber|chamber_icon }} {{ mandate.group.chamber.name }}
</dd>
<dt>{% trans "Party" %}</dt>
<dd>
{{ mandate.group|group_icon }} {{ mandate.group.name }}
{% if mandate.group.abbreviation %}({{ mandate.group.abbreviation }}){% endif %}
</dd>
{% endwith %}
<dt>{% trans "Biography" %}</dt>
<dd>{% blocktrans with birth_place=representative.birth_place birth_date=representative.birth_date|naturalday:'d/m/Y' %}Born in {{ birth_place }} the {{ birth_date }}{% endblocktrans %} ({{ representative.get_gender_display }})
<dd>{% blocktrans with birth_place=representative.birth_place birth_date=representative.birth_date|naturalday:'d/m/Y' %}Born on {{ birth_date }} in {{ birth_place }}{% endblocktrans %}
</dd>
<dt>{% trans "Links" %}</dt>
<dd>
{% for site in representative.social_websites %}
<a class="label label-primary" href="{{ site.url }}" target="_blank">
<img class="social-icon" src="{% static 'images' %}/social-{{ site.kind }}.png">
{% with kind=site.kind|capfirst %}
{% trans kind %}
{% endwith %}
</a>
{% endfor %}
{% for site in representative.chamber_websites %}
<a class="label label-primary" href="{{ site.url }}" target="_blank">
{% bootstrap_icon "user" %}
{% trans "Parliament page" %}
</a>
{% endfor %}
{% for site in representative.other_websites %}
<a class="label label-primary" href="{{ site.url }}" target="_blank">
{% bootstrap_icon "link" %}
{% trans "Website" %}
</a>
{% endfor %}
</dd>
{% if representative.social_websites|length or representative.chamber_websites|length or representative.other_websites|length %}
<dt>{% trans "Links" %}</dt>
<dd>
{% for site in representative.social_websites %}
<a class="label label-primary" href="{{ site.url }}" target="_blank">
<img class="social-icon" src="{% static 'images' %}/social-{{ site.kind }}.png">
{% with kind=site.kind|capfirst %}
{% trans kind %}
{% endwith %}
</a>
{% endfor %}
{% for site in representative.chamber_websites %}
<a class="label label-primary" href="{{ site.url }}" target="_blank">
{% bootstrap_icon "user" %}
{% trans "Parliament page" %}
</a>
{% endfor %}
{% for site in representative.other_websites %}
<a class="label label-primary" href="{{ site.url }}" target="_blank">
{% bootstrap_icon "link" %}
{% trans "Website" %}
</a>
{% endfor %}
{% for email in representative.email_set.all %}
<a class="label label-primary" href="mailto:{{ email.email }}">
<b>@</b>
{% trans "E-mail" %}
</a>
{% endfor %}
</dd>
{% endif %}
{% if representative.address_set.all|length or representative.phone_set.all|length %}
<dt>{% trans "Contact" %}</dt>
<dd>
{% trans "Other address" as default_label %}
{% for address in representative.address_set.all %}
<span class="label label-primary" data-toggle="tooltip" data-placement="bottom" title="{% if address.floor and address.office_number %}Floor {{ address.floor }} &ndash; office {{ address.office_number }} &ndash; {% endif %}{{ address.number }} {{ address.street }} &ndash; {{ address.city }} {{ address.postcode }}, {{ address.country.name }}">
{% bootstrap_icon "envelope" %}
{{ address.name|default:default_label }}
</span>
{% for phone in address.phones.all %}
<span class="label label-primary" data-toggle="tooltip" data-placement="bottom" title="{{ phone.number }}">
{% bootstrap_icon "earphone" %}
{{ address.name }}
</span>
{% endfor %}
{% endfor %}
{% for phone in representative.phone_set.all %}
<span class="label label-primary">
{% bootstrap_icon "earphone" %}
{{ phone.number }}
</span>
{% endfor %}
</dd>
{% endif %}
{# <dt>More infos</dt><dd><a><span class="label label-primary"><span class="glyphicon glyphicon-grain"></span> Facebook</span></a> <a><span class="label label-primary"><span class="glyphicon glyphicon-plane"></span> Twitter</span></a> <a><span class="label label-primary"><span class="glyphicon glyphicon-tree-conifer"></span> Parliement</span></a></dd> #}
</dl>
......
Supports Markdown
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