Commit 896346f5 authored by Nicolas Joyard's avatar Nicolas Joyard

Today's mep

parent e23a4a2e
......@@ -261,7 +261,7 @@ a:hover .custom-thumbnail-details {
position: relative;
}
.custom-listMEP .thumbnail .badge,
.representative-card .thumbnail .badge,
.position-button .badge {
position: absolute;
top: -0.5em;
......@@ -333,6 +333,12 @@ iframe {
background-size: cover;
}
.todays-mep .representative-card .img-responsive {
width: 150px;
height: 150px;
}
.representative-card h4 {
margin-top: 15px;
}
......
......@@ -21,6 +21,20 @@
</p>
</div>
<div class="col-md-4">
placeholder
</div>
<div class="col-md-4">
placeholder
</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 class="col-md-4">
<h3>{% trans "More information" %}</h3>
<div class="btn-group">
......
{% 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' %}
{% load i18n %}
{% load memopol_tags %}
{% block title %}{% trans "Members of the European Parliement" %}{% endblock %}
......@@ -15,47 +14,8 @@
{% include "blocks/listheader.html" %}
<div class="row card-list">
{% 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 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>
{% for mep in object_list %}
{% include "representatives/_representative_card.html" with representative=mep cols=4 %}
{% empty %}
{% trans "No representatives found !" %}
{% endfor %}
......
# coding: utf-8
import datetime
import random
from django.db.models import Q
from django.views import generic
from representatives.models import Representative
from representatives_positions.views import PositionFormMixin
from .representative_mixin import RepresentativeViewMixin
class HomeView(PositionFormMixin, generic.TemplateView):
class HomeView(PositionFormMixin, RepresentativeViewMixin,
generic.TemplateView):
template_name = 'home.html'
def get_context_data(self, **kwargs):
c = super(HomeView, self).get_context_data(**kwargs)
qs = Representative.objects
qs = qs.filter(Q(representative_score__score__lt=0) |
Q(representative_score__score__gt=0))
qs = self.prefetch_for_representative_country_and_main_mandate(qs)
random.seed(datetime.date.today().isoformat())
index = random.randint(0, qs.count() - 1)
c['todays_mep'] = qs.all()[index]
self.add_representative_country_and_main_mandate(c['todays_mep'])
return c
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