Commit ba69e530 authored by njoyard's avatar njoyard

Merge branch 'homepage-additions' into 'master'

Homepage additions

- Today's mep : random mep (seeded by current date) chosen from meps with nonzero score

See merge request !169
parents e23a4a2e 168915a2
from memopol_settings.models import Setting
from representatives.models import Chamber, Group from representatives.models import Chamber, Group
...@@ -13,3 +14,13 @@ def search_form_options(request): ...@@ -13,3 +14,13 @@ def search_form_options(request):
d['committees'] = Group.objects.filter(kind='committee') d['committees'] = Group.objects.filter(kind='committee')
return d return d
def intro_text(request):
d = {}
for s in Setting.objects.filter(pk__in=['HOMEPAGE_INTRO_TEXT',
'HOMEPAGE_INSTANCE_TEXT']):
d[s.pk] = s.comment
return d
...@@ -99,6 +99,10 @@ MIDDLEWARE_CLASSES = ( ...@@ -99,6 +99,10 @@ MIDDLEWARE_CLASSES = (
'django.contrib.sites.middleware.CurrentSiteMiddleware', 'django.contrib.sites.middleware.CurrentSiteMiddleware',
) )
if 'debug_toolbar' in INSTALLED_APPS:
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
# #
# Sessions # Sessions
# #
...@@ -130,6 +134,7 @@ TEMPLATE_LOADERS = ( ...@@ -130,6 +134,7 @@ TEMPLATE_LOADERS = (
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'django.template.context_processors.request', 'django.template.context_processors.request',
'memopol.context_processors.search_form_options', 'memopol.context_processors.search_form_options',
'memopol.context_processors.intro_text'
) )
# #
......
...@@ -92,7 +92,6 @@ a.custom-invisible, a.custom-invisible:hover, a.custom-invisible:focus { ...@@ -92,7 +92,6 @@ a.custom-invisible, a.custom-invisible:hover, a.custom-invisible:focus {
} }
/*************************************************************** /***************************************************************
Forms Forms
***************************************************************/ ***************************************************************/
...@@ -261,7 +260,7 @@ a:hover .custom-thumbnail-details { ...@@ -261,7 +260,7 @@ a:hover .custom-thumbnail-details {
position: relative; position: relative;
} }
.custom-listMEP .thumbnail .badge, .representative-card .thumbnail .badge,
.position-button .badge { .position-button .badge {
position: absolute; position: absolute;
top: -0.5em; top: -0.5em;
...@@ -333,6 +332,12 @@ iframe { ...@@ -333,6 +332,12 @@ iframe {
background-size: cover; background-size: cover;
} }
.todays-mep .representative-card .img-responsive {
width: 150px;
height: 150px;
}
.representative-card h4 { .representative-card h4 {
margin-top: 15px; margin-top: 15px;
} }
...@@ -365,6 +370,44 @@ iframe { ...@@ -365,6 +370,44 @@ iframe {
right: 0.5em; right: 0.5em;
} }
/***************************************************************
Themes
***************************************************************/
.theme-card .description {
margin: 0 1em;
line-height: 1.2em;
}
.theme-card .info-container {
display: flex;
flex-flow: row nowrap;
padding: 1em;
}
.theme-card .badge-container {
display: flex;
flex-flow: column nowrap;
justify-content: center;
}
.theme-card .badge-container .label {
margin: .25em 0;
}
.theme-card .chart-container {
flex-grow: 1;
height: 125px;
margin-left: .5em;
border: 1px solid #ddd;
background-image: url(../images/logo.png);
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
/*************************************************************** /***************************************************************
Dossiers Dossiers
***************************************************************/ ***************************************************************/
...@@ -401,6 +444,10 @@ iframe { ...@@ -401,6 +444,10 @@ iframe {
margin-left: 1em; margin-left: 1em;
} }
.proposal-details, .proposal-details td {
border: 0 !important;
}
/*************************************************************** /***************************************************************
Icones Icones
***************************************************************/ ***************************************************************/
...@@ -438,6 +485,7 @@ iframe { ...@@ -438,6 +485,7 @@ iframe {
margin-left: .5em; margin-left: .5em;
} }
.vote_positive { .vote_positive {
color: green; color: green;
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</h1> </h1>
<p class="lead text-center hidden-xs">{% trans "What is Memopol ?" %}</p> <p class="lead text-center hidden-xs">{% trans "What is Memopol ?" %}</p>
<p class="text-justify hidden-xs"> <p class="text-justify hidden-xs">
{% include "text/short_description.html" %} {{ HOMEPAGE_INTRO_TEXT }}
</p> </p>
{% if position_form %} {% if position_form %}
<div class="container-fluid hidden-xs"> <div class="container-fluid hidden-xs">
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
{% load i18n %} {% load i18n %}
{% load fontawesome %} {% load fontawesome %}
{% load staticfiles %} {% load staticfiles %}
{% load memopol_tags %}
{% block content %} {% block content %}
<div class="row"> <div class="row">
...@@ -13,14 +14,76 @@ ...@@ -13,14 +14,76 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h2>{% trans "What is Memopol ?" %}</h2>
<p> <p>
{% include "text/short_description.html" %} {{ HOMEPAGE_INTRO_TEXT }}
</p> </p>
<h2>{% trans "What about this instance ?" %}</h2>
<p> <p>
{% include "text/license.html" %} {{ HOMEPAGE_INSTANCE_TEXT }}
</p> </p>
</div> </div>
</div>
<div class="row">
<div class="col-md-4">
<h2>{% trans "Latest votes" %}</h2>
<table class="table table-responsive table-condensed">
<tr>
<th></th>
<th></th>
<th></th>
<th>{{ "for"|position_icon }}</th>
<th>{{ "against"|position_icon }}</th>
<th>{{ "abstain"|position_icon }}</th>
</tr>
{% for proposal in latest_votes %}
<tr class="proposal-title {% if forloop.counter0|divisibleby:2 %}active{% endif %}">
<td colspan="6">
<a href="{% url 'dossier-detail' proposal.dossier.pk %}">
{{ proposal.title }}
</a>
</td>
</tr>
<tr class="proposal-details {% if forloop.counter0|divisibleby:2 %}active{% endif %}">
<td>
{% for chamber in proposal.dossier.chambers %}
{{ chamber | chamber_icon }}
{% endfor %}
</td>
<td>
{% include "blocks/_themetags.html" with themes=proposal|proposal_themes %}
</td>
<td>{{ proposal.status|proposal_status_label:proposal.recommendation }}</td>
<td>{{ proposal.total_for }}</td>
<td>{{ proposal.total_against }}</td>
<td>{{ proposal.total_abstain }}</td>
</tr>
{% endfor %}
</table>
</div>
<div class="col-md-4">
<h2>{% trans "Featured themes" %}</h2>
{% for theme in featured_themes %}
{% include "memopol_themes/_theme_card.html" with theme=theme cols=12 %}
{% empty %}
{% trans "No currently featured theme :'(" %}
{% endfor %}
</div>
<div class="col-md-4 todays-mep">
<h2>{% trans "Today's Representative" %}</h2>
{% include "representatives/_representative_card.html" with representative=todays_mep cols=12 %}
</div>
</div>
<div class="row">
<div class="col-md-4"> <div class="col-md-4">
<h3>{% trans "More information" %}</h3> <h3>{% trans "More information" %}</h3>
<div class="btn-group"> <div class="btn-group">
...@@ -64,4 +127,14 @@ ...@@ -64,4 +127,14 @@
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-12">
<p>
<br><br>
{% include "text/license.html" %}
<br><br>
</p>
</div>
</div>
{% endblock %} {% endblock %}
{% load i18n %}
{% load fontawesome %}
<div class="col-xs-12 col-md-{{ cols|default:4 }} theme-card">
<div class="thumbnail">
<a href="{% url 'theme-detail' slug=theme.slug %}" class="custom-thumbnail custom-invisible">
<div class="row">
<div class="col-xs-12">
<h4 class="text-center">{{ theme.name }}</h4>
{# Double div needed for ellipsis to work #}
<div class="description ellipsis"><div>{{ theme.description|truncatewords:20 }}</div></div>
<div class="info-container">
<div class="badge-container">
{% if theme.nb_links > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Links' %}">
{% fontawesome_icon "link" %}
<span class="badge">{{ theme.nb_links }}</span>
</span>
{% endif %}
{% if theme.nb_dossiers > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Dossiers' %}">
{% fontawesome_icon "book" %}
<span class="badge">{{ theme.nb_dossiers }}</span>
</span>
{% endif %}
{% if theme.nb_proposals > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Proposals' %}">
{% fontawesome_icon "pencil" %}
<span class="badge">{{ theme.nb_proposals }}</span>
</span>
{% endif %}
{% if theme.nb_positions > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Public positions' %}">
{% fontawesome_icon "comment" %}
<span class="badge">{{ theme.nb_positions }}</span>
</span>
{% endif %}
</div>
<div class="chart-container">
</div>
</div>
</div>
</div>
</a>
</div>
</div>
\ No newline at end of file
...@@ -16,52 +16,7 @@ ...@@ -16,52 +16,7 @@
<div class="row card-list"> <div class="row card-list">
{% for theme in object_list %} {% for theme in object_list %}
<div class="col-xs-12 col-md-4 theme-card"> {% include "memopol_themes/_theme_card.html" with theme=theme %}
<div class="thumbnail">
<a href="{% url 'theme-detail' slug=theme.slug %}" class="custom-thumbnail custom-invisible">
<div class="row">
<div class="col-xs-12">
<h4 class="text-center">{{ theme.name }}</h4>
<p class="text-center lead">
&nbsp;
{% if theme.nb_links > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Links' %}">
{% fontawesome_icon "link" %}
<span class="badge">{{ theme.nb_links }}</span>
</span>
{% endif %}
{% if theme.nb_dossiers > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Dossiers' %}">
{% fontawesome_icon "book" %}
<span class="badge">{{ theme.nb_dossiers }}</span>
</span>
{% endif %}
{% if theme.nb_proposals > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Proposals' %}">
{% fontawesome_icon "pencil" %}
<span class="badge">{{ theme.nb_proposals }}</span>
</span>
{% endif %}
{% if theme.nb_positions > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Public positions' %}">
{% fontawesome_icon "comment" %}
<span class="badge">{{ theme.nb_positions }}</span>
</span>
{% endif %}
&nbsp;
</p>
</div>
</div>
</a>
</div>
</div>
{% endfor %} {% endfor %}
</div> </div>
......
{% load memopol_tags %}
<div class="col-xs-12 col-md-{{ cols|default: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 src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" class="img-responsive" style="background-image: url({{ representative.photo }});">
<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">
<br>
{% if representative.country %}
{{ representative.country|country_flag }}
{% endif %}
{% if representative.chamber %}
{{ representative.chamber|chamber_icon }}
{% endif %}
{% if representative.main_mandate.group %}
{{ representative.main_mandate.group|group_icon }}
{% endif %}
</p>
<p class="text-right">{{ representative.representative_score.score|score_badge }}</p>
</div>
</div>
</a>
</div>
</div>
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load i18n %} {% load i18n %}
{% load memopol_tags %}
{% block title %}{% trans "Members of the European Parliement" %}{% endblock %} {% block title %}{% trans "Members of the European Parliement" %}{% endblock %}
...@@ -15,47 +14,8 @@ ...@@ -15,47 +14,8 @@
{% include "blocks/listheader.html" %} {% include "blocks/listheader.html" %}
<div class="row card-list"> <div class="row card-list">
{% for representative in object_list %} {% for mep in object_list %}
<div class="col-xs-12 col-md-4 representative-card"> {% include "representatives/_representative_card.html" with representative=mep cols=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 src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" class="img-responsive" style="background-image: url({{ representative.photo }});">
<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">
<br>
{% if representative.country %}
{{ representative.country|country_flag }}
{% endif %}
{% if representative.chamber %}
{{ representative.chamber|chamber_icon }}
{% endif %}
{% if representative.main_mandate.group %}
{{ representative.main_mandate.group|group_icon }}
{% endif %}
</p>
<p class="text-right">{{ representative.representative_score.score|score_badge }}</p>
</div>
</div>
</a>
</div>
</div>
{% empty %} {% empty %}
{% trans "No representatives found !" %} {% trans "No representatives found !" %}
{% endfor %} {% endfor %}
......
{% load i18n %}
{% blocktrans %}
Political Memory is a tool designed by La Quadrature du Net to help
citizens to reach their representatives and
track their voting records on issues related to fundamental
freedoms online.
{% endblocktrans %}
...@@ -118,3 +118,8 @@ def score_badge(score, tooltip=None): ...@@ -118,3 +118,8 @@ def score_badge(score, tooltip=None):
@register.filter @register.filter
def cast_str(val): def cast_str(val):
return str(val) return str(val)
@register.filter
def proposal_themes(proposal):
return set(proposal.themes.all()) | set(proposal.dossier.themes.all())
...@@ -8,6 +8,7 @@ class BaseTest(ResponseDiffTestMixin, test.TestCase): ...@@ -8,6 +8,7 @@ class BaseTest(ResponseDiffTestMixin, test.TestCase):
""" """
Common queries Common queries
- 1 for settings
- 5 for search forms - 5 for search forms
- 1 for chambers - 1 for chambers
- 1 for countries - 1 for countries
...@@ -18,7 +19,7 @@ class BaseTest(ResponseDiffTestMixin, test.TestCase): ...@@ -18,7 +19,7 @@ class BaseTest(ResponseDiffTestMixin, test.TestCase):
- 1 for representatives - 1 for representatives
- 1 for themes - 1 for themes
""" """
left_pane_queries = 7 left_pane_queries = 8
def setUp(self): def setUp(self):
RepresentativeScore.refresh() RepresentativeScore.refresh()
......
<div class="col-xs-12 col-md-4 theme-card"> <div class="col-xs-12 col-md-4 theme-card">
<div class="thumbnail"> <div class="thumbnail">
<a class="custom-thumbnail custom-invisible" href="/themes/acta/"> <a class="custom-thumbnail custom-invisible" href="/themes/acta/">
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<h4 class="text-center">ACTA</h4> <h4 class="text-center">ACTA</h4>
<p class="text-center lead">
  <div class="description ellipsis"><div>Anti-Counterfeiting Trade Agreement</div></div>
<div class="info-container">
<div class="badge-container">
<span class="label label-default" data-placement="bottom" data-toggle="tooltip" title="Dossiers"> <span class="label label-default" data-placement="bottom" data-toggle="tooltip" title="Dossiers">
<i class="fa fa-book" title=""></i> <i class="fa fa-book" title=""></i>
<span class="badge">3</span> <span class="badge">3</span>
</span> </span>
</div>
  <div class="chart-container">
</p>
</div> </div>
</div> </div>
</a>
</div> </div>
</div> </div>
</a>
</div>
</div>
--- ---
<div class="col-xs-12 col-md-4 theme-card"> <div class="col-xs-12 col-md-4 theme-card">
<div class="thumbnail"> <div class="thumbnail">
<a class="custom-thumbnail custom-invisible" href="/themes/etat-durgence/"> <a class="custom-thumbnail custom-invisible" href="/themes/etat-durgence/">
<div class="row"> <div class="row">
<div class="col-xs-12">