Commit 5061b4a2 authored by Nicolas Joyard's avatar Nicolas Joyard

Add preliminary chamber cards on homepage

parent 47b8e95f
Pipeline #197 passed with stage
in 8 minutes and 53 seconds
...@@ -375,28 +375,36 @@ iframe { ...@@ -375,28 +375,36 @@ iframe {
Themes Themes
***************************************************************/ ***************************************************************/
.theme-card .description { .theme-card .description,
.chamber-card .description {
margin: 0 1em; margin: 0 1em;
line-height: 1.2em; line-height: 1.2em;
} }
.theme-card .info-container { .theme-card .info-container,
.chamber-card .info-container,
.chamber-card .title-container {
display: flex; display: flex;
flex-flow: row nowrap; flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
padding: 1em; padding: 1em;
} }
.theme-card .badge-container { .theme-card .badge-container,
.chamber-card .badge-container {
display: flex; display: flex;
flex-flow: column nowrap; flex-flow: column nowrap;
justify-content: center; justify-content: center;
} }
.theme-card .badge-container .label { .theme-card .badge-container .label,
.chamber-card .badge-container .label {
margin: .25em 0; margin: .25em 0;
} }
.theme-card .chart-container { .theme-card .chart-container,
.chamber-card .chart-container {
flex-grow: 1; flex-grow: 1;
height: 125px; height: 125px;
margin-left: .5em; margin-left: .5em;
...@@ -408,6 +416,14 @@ iframe { ...@@ -408,6 +416,14 @@ iframe {
background-repeat: no-repeat; background-repeat: no-repeat;
} }
.chamber-card .chart-container {
margin: 1em;
}
.chamber-card h4 {
margin: 0;
}
/*************************************************************** /***************************************************************
Dossiers Dossiers
***************************************************************/ ***************************************************************/
......
{% load i18n %}
{% load fontawesome %}
{% load memopol_tags %}
<div class="col-xs-12 col-md-{{ cols|default:4 }} chamber-card">
<div class="thumbnail">
<div class="row">
<div class="col-xs-12">
<div class="title-container">
<h4 class="text-center">
{{ chamber.name }}
</h4>
{{ chamber|chamber_icon }}
</div>
<div class="description">
{% blocktrans with dossiers=chamber.nb_dossiers proposals=chamber.nb_proposals %}
<b>{{ dossiers }} dossiers</b> and <b>{{ proposals }} proposals</b>
{% endblocktrans %}
</div>
<div class="chart-container">
</div>
</div>
</div>
</div>
</div>
...@@ -83,6 +83,16 @@ ...@@ -83,6 +83,16 @@
</div> </div>
<div class="row">
<div class="col-md-12">
<h2>{% trans "Chambers in this instance" %}</h2>
</div>
{% for chamber in chambers %}
{% include "blocks/_chamber_card.html" with chamber=chamber %}
{% endfor %}
</div>
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<h3>{% trans "More information" %}</h3> <h3>{% trans "More information" %}</h3>
......
...@@ -9,19 +9,23 @@ class NavigationPaneTest(BaseTest): ...@@ -9,19 +9,23 @@ class NavigationPaneTest(BaseTest):
self.client.get(self.url) self.client.get(self.url)
""" """
Today mep - 3 for Today mep
- 1 for count reps with non null score - 1 for count reps with non null score
- 1 for random mep - 1 for random mep
- 1 for prefetch main mandate - 1 for prefetch main mandate
Latest votes - 6 for Latest votes
- 1 for latest votes count setting - 1 for latest votes count setting
- 1 for latest votes (proposal) - 1 for latest votes (proposal)
- 1 for prefetching latest votes themes - 1 for prefetching latest votes themes
- 1 for prefetching latest votes dossier themes - 1 for prefetching latest votes dossier themes
- 1 for prefetching latest votes dossier documents - 1 for prefetching latest votes dossier documents
- 1 for prefetching latest votes dossier documents chambers - 1 for prefetching latest votes dossier documents chambers
Featured themes - 1 for Featured themes
- 1 for featured themes - 1 for featured themes
- 0 for Chambers
- 1 for chambers and dossier/proposal counts
=> note: django optimizes out the chamber query for left pane
forms so this one actually does not add 1 to query count
""" """
home_queries = 10 home_queries = 10
......
...@@ -6,7 +6,7 @@ import random ...@@ -6,7 +6,7 @@ import random
from django.db.models import Q, Count from django.db.models import Q, Count
from django.views import generic from django.views import generic
from representatives.models import Representative from representatives.models import Chamber, Representative
from representatives_positions.views import PositionFormMixin from representatives_positions.views import PositionFormMixin
from representatives_votes.models import Proposal from representatives_votes.models import Proposal
...@@ -57,4 +57,12 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin, ...@@ -57,4 +57,12 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin,
'dossier__documents__chamber') \ 'dossier__documents__chamber') \
.order_by('-datetime')[0:num] .order_by('-datetime')[0:num]
# Chambers
c['chambers'] = Chamber.objects.all() \
.annotate(
nb_dossiers=Count('documents__dossier', distinct=True),
nb_proposals=Count('documents__dossier__proposals',
distinct=True))
return c return c
...@@ -38,7 +38,7 @@ class Dossier(TimeStampedModel): ...@@ -38,7 +38,7 @@ class Dossier(TimeStampedModel):
class Document(TimeStampedModel): class Document(TimeStampedModel):
dossier = models.ForeignKey(Dossier, related_name='documents') dossier = models.ForeignKey(Dossier, related_name='documents')
chamber = models.ForeignKey(Chamber) chamber = models.ForeignKey(Chamber, related_name='documents')
title = models.CharField(max_length=1000) title = models.CharField(max_length=1000)
kind = models.CharField(max_length=255, blank=True, default='') kind = models.CharField(max_length=255, blank=True, default='')
link = models.URLField(max_length=1000) link = models.URLField(max_length=1000)
......
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