Commit 1d5b60d3 authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Implement dossier list

parent 377706f9
<div class="col-xs-12 col-md-4 dossier-card">
<div class="thumbnail">
<a class="custom-thumbnail custom-invisible" href="/votes/dossier/28147/">
<div class="row">
<div class="col-xs-12">
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
<p class="text-center lead">
 
<span class="label label-default" data-placement="bottom" data-toggle="tooltip" title="Proposals">
<span class="glyphicon glyphicon-file"></span>
<span class="badge">3</span>
</span>
<span class="label label-default" data-placement="bottom" data-toggle="tooltip" title="Recommendations">
<span class="glyphicon glyphicon-eye-open"></span>
<span class="badge">3</span>
</span>
<span class="label label-default" data-placement="bottom" data-toggle="tooltip" title="Documents">
<span class="glyphicon glyphicon-file"></span>
<span class="badge">1</span>
</span>
 
</p>
<p class="text-center">
 
<span class="chamber-icon" style="background-image: url(/static/collected/images/chamber-ep.png)"></span>
<span class="tag">ACTA</span>
 
</p>
</div>
</div>
</a>
</div>
</div>
\ No newline at end of file
{
"status_code": 200
}
\ No newline at end of file
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
<li>
<a href="?&amp;sort_by=nb_proposals">proposals</a>
</li>
---
<li class="disabled">
<a href="?&amp;sort_by=nb_recommendations">recommendations</a>
</li>
---
<li>
<a href="?&amp;sort_by=title">title</a>
</li>
---
<li>
<a href="?&amp;sort_dir=asc">ascending</a>
</li>
---
<li class="disabled">
<a href="?&amp;sort_dir=desc">descending</a>
</li>
\ No newline at end of file
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
from .base import BaseTest
class DossierListTest(BaseTest):
url = '/votes/dossier/'
def test_queries(self):
# First query to set session variables
self.client.get(self.url)
with self.assertNumQueries(self.left_pane_queries + 6):
"""
Left pane queries plus:
- 1 for session key
- 1 for dossier count (pagination)
- 1 for dossiers
- 1 for reverse relation on documents
- 1 for reverse relation on document chambers
- 1 for reverse relation on themes
"""
self.client.get(self.url)
def test_cards(self):
self.selector_test('.dossier-card')
def test_navbar_order_options(self):
self.selector_test('#listheader #orderby li, #listheader #orderdir li')
def test_navbar_order_title_asc(self):
self.selector_test('.dossier-card h4',
'%s?sort_by=title&sort_dir=asc' % self.url)
def test_navbar_order_title_desc(self):
self.selector_test('.dossier-card h4',
'%s?sort_by=title&sort_dir=desc' % self.url)
def test_navbar_order_nb_proposals_asc(self):
self.selector_test('.dossier-card h4',
'%s?sort_by=nb_proposals&sort_dir=asc' % self.url)
def test_navbar_order_nb_proposals_desc(self):
self.selector_test('.dossier-card h4',
'%s?sort_by=nb_proposals&sort_dir=desc' % self.url)
def test_navbar_order_nb_recommendations_asc(self):
self.selector_test('.dossier-card h4',
'%s?sort_by=nb_recommendations&sort_dir=asc' % self.url)
def test_navbar_order_nb_recommendations_desc(self):
self.selector_test('.dossier-card h4',
'%s?sort_by=nb_recommendations&sort_dir=desc' % self.url)
...@@ -14,21 +14,19 @@ class DossierList(PaginationMixin, SortMixin, generic.ListView): ...@@ -14,21 +14,19 @@ class DossierList(PaginationMixin, SortMixin, generic.ListView):
current_filter = None current_filter = None
queryset = Dossier.objects.prefetch_related( queryset = Dossier.objects.prefetch_related(
'proposals', 'documents__chamber',
'proposals__recommendation', 'themes'
'documents',
'documents__chamber'
).annotate( ).annotate(
nb_proposals=Count('proposals'), nb_proposals=Count('proposals', distinct=True),
nb_recomm=Count('proposals__recommendation') nb_recommendations=Count('proposals__recommendation', distinct=True),
nb_documents=Count('documents', distinct=True)
) )
sort_fields = { sort_fields = {
'title': 'title', 'title': 'title',
'reference': 'reference', 'nb_recommendations': 'recommendations',
'nb_recomm': 'recommendations',
'nb_proposals': 'proposals', 'nb_proposals': 'proposals',
} }
sort_default_field = 'nb_recomm' sort_default_field = 'nb_recommendations'
sort_default_dir = 'desc' sort_default_dir = 'desc'
def dossier_filter(self, qs): def dossier_filter(self, qs):
......
...@@ -22,12 +22,19 @@ body { ...@@ -22,12 +22,19 @@ body {
margin-top: 1em; margin-top: 1em;
} }
.tag {
border: 1px solid #487ed6;
color: #487ed6;
padding: .2em .6em;
border-radius: .25em;
}
/*************************************************************** /***************************************************************
Typographie Typographie
***************************************************************/ ***************************************************************/
@font-face { @font-face {
font-family: Propaganda; font-family: Propaganda, fixed;
src: url(../fonts/PROPAGAN.ttf); src: url(../fonts/PROPAGAN.ttf);
} }
...@@ -36,7 +43,7 @@ body, .panel-title { ...@@ -36,7 +43,7 @@ body, .panel-title {
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
font-family: Propaganda; font-family: Propaganda, fixed;
} }
h1 { h1 {
...@@ -344,6 +351,7 @@ iframe { ...@@ -344,6 +351,7 @@ iframe {
width: 1.75em; width: 1.75em;
height: 1.75em; height: 1.75em;
line-height: initial; line-height: initial;
vertical-align: bottom;
} }
.flag-icon:before { .flag-icon:before {
......
{% extends "base.html" %} {% extends "base.html" %}
{% load bootstrap3 %}
{% load i18n %} {% load i18n %}
{% load memopol_tags %}
{% load humanize %} {% load humanize %}
{% block title %}{% trans "Dosssiers" %}{% endblock %} {% block title %}{% trans "Dossiers" %}{% endblock %}
{% block content %} {% block content %}
<h1 class="text-center">{% trans "Dossiers" %}</h1> <h1 class="text-center">{% trans "Dossiers" %}</h1>
<p class="lead text-center"> <p class="lead text-center">
{% blocktrans count counter=paginator.count %}{{ counter }} dossier{% plural %}{{ counter }} dossier{% endblocktrans %}{% if search %}{% blocktrans %}on {{ search }}{% endblocktrans %}{% endif %}. {% blocktrans count counter=paginator.count %}{{ counter }} dossier{% plural %}{{ counter }} dossiers{% endblocktrans %}.
</p> </p>
{% comment %} {% include "blocks/listheader.html" %}
<!-- TODO: ordering -->
<br/> <div class="row card-list">
<p> {% for dossier in object_list %}
<div class="dropdown" style="display:inline-block;"> <div class="col-xs-12 col-md-4 dossier-card">
Order by <div class="thumbnail">
<button class="btn btn-default dropdown-toggle" type="button" id="orderby" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <a href="{% url 'dossier-detail' dossier.pk %}" class="custom-thumbnail custom-invisible">
Name <div class="row">
<span class="caret"></span>
</button> <div class="col-xs-12">
<ul class="dropdown-menu" aria-labelledby="orderby"> <h4 class="text-center">{{ dossier.title }}</h4>
<li class="disabled"><a href="#">Name</a></li>
<li><a href="#">Recent</a></li> <p class="text-center lead">
</ul> &nbsp;
</div>
</p> {% if dossier.nb_proposals > 0 %}
{% endcomment %} <span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Proposals' %}">
{% bootstrap_icon "file" %}
<div class="col-xs-12 col-md-4"> <span class="badge">{{ dossier.nb_proposals }}</span>
{% for dossier in object_list %} </span>
<div class="thumbnail"> {% endif %}
<a href="{{ dossier.get_absolute_url }}" class="custom-thumbnail custom-invisible">
<div class="row"> {% if dossier.nb_recommendations > 0 %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Recommendations' %}">
<div class="col-xs-12"> {% bootstrap_icon "eye-open" %}
<h4 class="text-center">{{ dossier.title }}</h4> <span class="badge">{{ dossier.nb_recommendations }}</span>
<p class="text-center">{% trans "Last updated" %} {{ dossier.updated|naturalday }}</p> </span>
{% endif %}
<p class="text-center lead">
{% comment %} {% if dossier.nb_documents > 0 %}
<!-- We don't have this data --> <span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Documents' %}">
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Upcoming envents"><span class="glyphicon glyphicon-calendar"></span> {% bootstrap_icon "file" %}
<span class="badge">5</span> <span class="badge">{{ dossier.nb_documents }}</span>
</span> </span>
{% endcomment %} {% endif %}
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Votes"><span class="glyphicon glyphicon-check"></span>
<span class="badge">{{ dossier.votes_count }}</span> &nbsp;
</span> </p>
{% comment %}
<!-- We don't have this data --> <p class="text-center">
<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Public positions"><span class="glyphicon glyphicon-comment"></span> &nbsp;
<span class="badge">42</span>
</span> {% for chamber in dossier.chambers %}
{% endcomment %} {{ chamber|chamber_icon }}
</p> {% endfor %}
{% comment %} {% for theme in dossier.themes.all %}
<!-- TODO --> <span class="tag">{{ theme.name }}</span>
<div class="alert alert-info text-center" role="alert"><span class="glyphicon glyphicon-alert"></span> A campaign is currently ongoing with La Quadrature. <a href="#" class="alert-link">Check it out!</a> </div> {% endfor %}
{% endcomment %}
</div>
</div>
</a>
</div>
{% if forloop.counter|divisibleby:3 %}</div><div class="col-xs-12 col-md-4">{% endif %} &nbsp;
{% endfor %} </p>
</div>
</div>
</a>
</div>
</div>
{% endfor %}
</div> </div>
{% include "blocks/_pagination.html" %} {% include "blocks/listfooter.html" %}
{% endblock %} {% endblock %}
Supports Markdown
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