Commit 16e3f09c authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Factor dossier list display

parent 19059fb1
<tr class="dossier">
<td>
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-an.png)" title="Assemblée nationale"></span>
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-sen.png)" title="Sénat"></span>
</td>
<td>
<a href="/votes/dossier/15426/">
Pouvoirs publics : prorogation de l'application de la loi relative à l'état d'urgence
</a>
</td>
<td>14/application_loi_55-385_prorogation</td>
</tr>
---
<tr class="dossier">
<td>
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-an.png)" title="Assemblée nationale"></span>
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-sen.png)" title="Sénat"></span>
</td>
<td>
<a href="/votes/dossier/15424/">
Pouvoirs publics : application de la loi relative à l’état d’urgence
</a>
</td>
<td>14/prorogation_application_loi_55-385</td>
</tr>
---
<tr class="dossier">
<td>
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-an.png)" title="Assemblée nationale"></span>
</td>
<td>
<a href="/votes/dossier/15409/">
Pouvoirs publics : prorogation de l'application de la loi sur l'état d'urgence
</a>
</td>
<td>14/loi_55-385_prorogation_application</td>
</tr>
---
<tr class="dossier">
<td>
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-an.png)" title="Assemblée nationale"></span>
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-sen.png)" title="Sénat"></span>
</td>
<td>
<a href="/votes/dossier/15407/">
Pouvoirs publics : prorogation de l'état d'urgence
</a>
</td>
<td>14/prorogation_loi_55-385</td>
</tr>
\ No newline at end of file
......@@ -7,10 +7,11 @@ class ThemeDossiersTest(ThemeBaseTest):
"""
Theme base queries plus
- 1 for dossiers
- 1 for related documents
- 1 for related documents/chambers
- 1 for reverse relation on documents
- 1 for reverse relation on document chambers
- 1 for reverse relation on themes
"""
queries = ThemeBaseTest.queries + 3
queries = ThemeBaseTest.queries + 4
def test_queries(self):
self.do_query_test()
......
......@@ -16,7 +16,7 @@ class ThemeDetailDossiers(ThemeDetailBase):
models.Prefetch(
'dossiers',
Dossier.objects.order_by('-pk')
.prefetch_related('documents__chamber')
.prefetch_related('documents__chamber', 'themes')
)
)
return qs
......
{% load i18n %}
{% load bootstrap3 %}
{% load memopol_tags %}
<div class="row card-list">
{% for dossier in dossiers %}
<div class="col-xs-12 col-md-4 dossier-card">
<div class="thumbnail">
<a href="{% url 'dossier-detail' dossier.pk %}" class="custom-thumbnail custom-invisible">
<div class="row">
<div class="col-xs-12">
<h4 class="text-center">{{ dossier.title }}</h4>
<p class="text-center lead">
&nbsp;
{% if dossier.nb_proposals > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Proposals' %}">
{% bootstrap_icon "pencil" %}
<span class="badge">{{ dossier.nb_proposals }}</span>
</span>
{% endif %}
{% if dossier.nb_recommendations > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Recommendations' %}">
{% bootstrap_icon "eye-open" %}
<span class="badge">{{ dossier.nb_recommendations }}</span>
</span>
{% endif %}
{% if dossier.nb_documents > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Documents' %}">
{% bootstrap_icon "file" %}
<span class="badge">{{ dossier.nb_documents }}</span>
</span>
{% endif %}
&nbsp;
</p>
<p class="text-center">
&nbsp;
{% for chamber in dossier.chambers %}
{{ chamber|chamber_icon }}
{% endfor %}
{% include "blocks/_themetags.html" with themes=dossier.themes.all %}
&nbsp;
</p>
</div>
</div>
</a>
</div>
</div>
{% endfor %}
</div>
\ No newline at end of file
......@@ -5,33 +5,6 @@
{% block theme_content %}
<table class="table table-responsive">
<tr>
<th>
{% trans "Chambers" %}
</th>
<th>
{% trans "Dossier" %}
</th>
<th>
{% trans "Reference" %}
</th>
</tr>
{% for dossier in dossiers %}
<tr class="dossier">
<td>
{% for chamber in dossier.chambers %}
{{ chamber|chamber_small_icon }}
{% endfor %}
</td>
<td>
<a href="{% url 'dossier-detail' dossier.pk %}">
{{ dossier.title }}
</a>
</td>
<td>{{ dossier.reference }}</td>
</tr>
{% endfor %}
</table>
{% include "blocks/_dossier_blocks.html" %}
{% endblock %}
......@@ -8,69 +8,16 @@
{% block title %}{% trans "Dossiers" %}{% endblock %}
{% block content %}
<h1 class="text-center">{% trans "Dossiers" %}</h1>
<p class="lead text-center">
{% blocktrans count counter=paginator.count %}{{ counter }} dossier{% plural %}{{ counter }} dossiers{% endblocktrans %}.
</p>
{% include "blocks/listheader.html" %}
<h1 class="text-center">{% trans "Dossiers" %}</h1>
<p class="lead text-center">
{% blocktrans count counter=paginator.count %}{{ counter }} dossier{% plural %}{{ counter }} dossiers{% endblocktrans %}.
</p>
<div class="row card-list">
{% for dossier in object_list %}
<div class="col-xs-12 col-md-4 dossier-card">
<div class="thumbnail">
<a href="{% url 'dossier-detail' dossier.pk %}" class="custom-thumbnail custom-invisible">
<div class="row">
{% include "blocks/listheader.html" %}
<div class="col-xs-12">
<h4 class="text-center">{{ dossier.title }}</h4>
{% include "blocks/_dossier_blocks.html" with dossiers=object_list %}
<p class="text-center lead">
&nbsp;
{% if dossier.nb_proposals > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Proposals' %}">
{% bootstrap_icon "pencil" %}
<span class="badge">{{ dossier.nb_proposals }}</span>
</span>
{% endif %}
{% if dossier.nb_recommendations > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Recommendations' %}">
{% bootstrap_icon "eye-open" %}
<span class="badge">{{ dossier.nb_recommendations }}</span>
</span>
{% endif %}
{% if dossier.nb_documents > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Documents' %}">
{% bootstrap_icon "file" %}
<span class="badge">{{ dossier.nb_documents }}</span>
</span>
{% endif %}
&nbsp;
</p>
<p class="text-center">
&nbsp;
{% for chamber in dossier.chambers %}
{{ chamber|chamber_icon }}
{% endfor %}
{% include "blocks/_themetags.html" with themes=dossier.themes.all %}
&nbsp;
</p>
</div>
</div>
</a>
</div>
</div>
{% endfor %}
</div>
{% include "blocks/listfooter.html" %}
{% include "blocks/listfooter.html" %}
{% endblock %}
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