Commit f40adcc4 authored by Nicolas Joyard's avatar Nicolas Joyard

Fix representative cards and add tests

parent 7f8f2a36
......@@ -136,7 +136,7 @@ def group_icon(group):
url = static('images/group-%s.png' % cssify('%s-%s' % (
group.chamber.abbreviation, group.abbreviation)))
return mark_safe(
u'<span class="group-icon" style="background-image: url({url})">&nbsp;'
u'<span class="group-icon" style="background-image: url({url})">'
u'</span>'.format(url=url, name=group.abbreviation))
......
from django import test
from responsediff.test import ResponseDiffTestMixin
class BaseTest(ResponseDiffTestMixin, test.TestCase):
fixtures = ['smaller_sample.json']
"""
Common queries
- One for chambers
- One for countries
- One for parties
- One for committees
- One for delegations
"""
left_pane_queries = 5
def selector_test(self, selector):
self.assertResponseDiffEmpty(self.client.get(self.url), selector)
from django import test
from responsediff.test import ResponseDiffTestMixin
from .base import BaseTest
class NavigationPaneTest(ResponseDiffTestMixin, test.TestCase):
class NavigationPaneTest(BaseTest):
url = '/'
fixtures = ['smaller_sample.json']
"""
Common queries
- One for chambers
- One for countries
- One for parties
- One for committees
- One for delegations
"""
queries = 5
def selector_test(self, selector):
self.assertResponseDiffEmpty(test.Client().get(self.url), selector)
def test_queries(self):
with self.assertNumQueries(self.queries):
test.Client().get(self.url)
# First query to set session variables
self.client.get(self.url)
with self.assertNumQueries(self.left_pane_queries):
self.client.get(self.url)
def test_rep_search_chambers(self):
self.selector_test('#form-rep #chamber-rep option')
......
from django import test
from .base import BaseTest
class RepresentativeListTest(BaseTest):
url = '/legislature/representative/'
def test_queries(self):
# First query to set session variables
self.client.get(self.url)
with self.assertNumQueries(self.left_pane_queries + 4):
"""
Left pane queries plus:
- 1 for session key
- 1 for representative count (pagination)
- 1 for representatives
- 1 for reverse relation on country
"""
self.client.get(self.url)
def test_cards(self):
self.selector_test('.representative-card')
......@@ -29,7 +29,7 @@ body, .panel-title {
}
h1, h2, h3, h4, h5, h6 {
font-family: Propaganda;
font-family: Propaganda;
}
h1 {
......@@ -152,14 +152,14 @@ select:focus, select.form-control:focus {
.custom-nav .custom-plus {
margin: -1.5em 0 1.5em 0;
}
.custom-nav, .custom-cardMEP{
-moz-box-shadow: 0px 0px 5px 0px #656565;
-webkit-box-shadow: 0px 0px 5px 0px #656565;
-o-box-shadow: 0px 0px 5px 0px #656565;
box-shadow: 0px 0px 5px 0px #656565;
}
.custom-nav {
height: 100%;
position: fixed;
......@@ -212,7 +212,7 @@ select:focus, select.form-control:focus {
.custom-thumbnail-details {
opacity: 0;
transition: opacity 0.2s;
position: absolute;
top: 0;
background: white;
......@@ -222,7 +222,7 @@ select:focus, select.form-control:focus {
color: #666666;
}
a.custom-thumbnail:hover .custom-thumbnail-details {
a:hover .custom-thumbnail-details {
opacity: 1;
}
......@@ -273,7 +273,7 @@ iframe {
border: none;
width: 100%;
height: 700px;
}
.nav-tabs>li>a, .nav-tabs>li>a:focus {
......@@ -325,20 +325,31 @@ iframe {
/***************************************************************
Icones
***************************************************************/
.chamber-icon, .group-icon, .flag-icon {
width: 1.75em;
height: 1.75em;
line-height: initial;
}
.flag-icon:before {
content: initial;
}
.chamber-icon, .group-icon {
background-size: cover;
/* background-size: contain; */
background-size: contain;
background-position: 50%;
background-repeat: no-repeat;
position: relative;
display: inline-block;
width: 1.3333333333333333em;
line-height: 1em;
}
.icon-badge + .icon-badge {
margin-left: .5em;
}
......
......@@ -12,9 +12,9 @@
</p>
<div class="row">
<a href="?{{ searchparameters }}&csv" class="btn btn-default">
<span class="glyphicon glyphicon-file"> {% trans "Download as CSV." %}</span>
</a>
<a href="?{{ searchparameters }}&csv" class="btn btn-default">
<span class="glyphicon glyphicon-file"> {% trans "Download as CSV." %}</span>
</a>
{% comment %}
<!-- TODO: layout & ordering -->
......@@ -48,65 +48,50 @@
{% endcomment %}
</div>
<br/>
<div class="row">
{% for representative in object_list %}
<div class="col-xs-12 col-md-4">
<div class="thumbnail">
<a href="{% url "representative-detail" slug=representative.slug %}" class="custom-thumbnail custom-invisible">
<div class="row">
<div class="col-xs-5">
<img class="img-responsive" src="{{ representative.photo }}" width="158px">
<div class="custom-thumbnail-details">
<p>
{{ representative.country|country_flag }} {{ representative.country.name }}<br>
<!-- Group -->
{{ representative.main_mandate }}<br>
{% comment %}
<!-- ? -->
<span class="glyphicon glyphicon-briefcase "></span> {{ representative. }}
{% endcomment %}
</p>
</div>
</div>
{% for representative in object_list %}
<div class="col-xs-12 col-md-4 representative-card">
<div class="thumbnail">
<a href="{% url 'representative-detail' slug=representative.slug %}" class="custom-thumbnail custom-invisible">
<div class="row">
<div class="col-xs-5">
<img class="img-responsive" src="{{ representative.photo }}" width="158">
<div class="custom-thumbnail-details">
{% if representative.country %}
<div class="icon-badge-detail">{{ representative.country|country_flag }} {{ representative.country.name }}</div>
{% endif %}
{% if representative.chamber %}
<div class="icon-badge-detail">{{ representative.chamber|chamber_icon }} {{ representative.chamber.name }}</div>
{% endif %}
{% if representative.main_mandate.group %}
<div class="icon-badge-detail">{{ representative.main_mandate.group|group_icon }} {{ representative.main_mandate.group.abbreviation }}</div>
{% endif %}
</div>
</div>
<div class="col-xs-7">
<h4 class="text-center">{{ representative.full_name }}</h4>
<p class="text-center">
{% if representative.country %}
<a href="{% country_url representative.country %}" title="{{ representative.country.name }}">
{{ representative.country|country_flag }}
</a>
{% endif %}
{% if representative.chamber %}
<a href="{% chamber_url representative.chamber %}" title="{{ representative.chamber.name }}">
{{ representative.chamber|chamber_icon }}
</a>
{% endif %}
{% if representative.main_mandate.group %}
<a href="{% group_url representative.main_mandate.group %}" title="{{ representative.main_mandate.group.name }}">
{{ representative.main_mandate.group|group_icon }}
</a>
{% endif %}
</p>
{% comment %} ?
<p class="text-center small">
<span class="label label-primary"><span class="glyphicon glyphicon-pushpin "></span></span>
<span class="label label-primary"><span class="glyphicon glyphicon-pushpin "></span></span>
<span class="label label-primary"><span class="glyphicon glyphicon-pushpin "></span></span>
</p>
{% endcomment %}
<p class="text-right"><span class="badge">{{ representative.score.score }}</span></p>
</div>
<div class="col-xs-7">
<h4 class="text-center">{{ representative.full_name }}</h4>
<p class="text-center">
{% if representative.country %}
<a class="icon-badge" href="{% country_url representative.country %}" title="{{ representative.country.name }}">{{ representative.country|country_flag }}</a>
{% endif %}
{% if representative.chamber %}
<a class="icon-badge" href="{% chamber_url representative.chamber %}" title="{{ representative.chamber.name }}">{{ representative.chamber|chamber_icon }}</a>
{% endif %}
{% if representative.main_mandate.group %}
<a class="icon-badge" href="{% group_url representative.main_mandate.group %}" title="{{ representative.main_mandate.group.name }}">{{ representative.main_mandate.group|group_icon }}</a>
{% endif %}
</p>
<p class="text-right"><span class="badge">{{ representative.score.score }}</span></p>
</div>
</div>
</a>
</div>
</a>
</div>
{% empty %}
</div>
{% empty %}
{% trans "No representatives found !" %}
{% endfor %}
{% endfor %}
</div>
{% include "pagination.html" %}
......
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