Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Political Memory
memopol
Commits
1d5b60d3
Commit
1d5b60d3
authored
Aug 20, 2016
by
Nicolas Joyard
Browse files
Implement dossier list
parent
377706f9
Changes
20
Hide whitespace changes
Inline
Side-by-side
memopol/tests/response_fixtures/DossierListTest.test_cards.content
0 → 100644
View file @
1d5b60d3
<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
memopol/tests/response_fixtures/DossierListTest.test_cards.metadata
0 → 100644
View file @
1d5b60d3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_nb_proposals_asc.content
0 → 100644
View file @
1d5b60d3
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_nb_proposals_asc.metadata
0 → 100644
View file @
1d5b60d3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_nb_proposals_desc.content
0 → 100644
View file @
1d5b60d3
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_nb_proposals_desc.metadata
0 → 100644
View file @
1d5b60d3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_nb_recommendations_asc.content
0 → 100644
View file @
1d5b60d3
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_nb_recommendations_asc.metadata
0 → 100644
View file @
1d5b60d3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_nb_recommendations_desc.content
0 → 100644
View file @
1d5b60d3
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_nb_recommendations_desc.metadata
0 → 100644
View file @
1d5b60d3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_options.content
0 → 100644
View file @
1d5b60d3
<li>
<a href="?&sort_by=nb_proposals">proposals</a>
</li>
---
<li class="disabled">
<a href="?&sort_by=nb_recommendations">recommendations</a>
</li>
---
<li>
<a href="?&sort_by=title">title</a>
</li>
---
<li>
<a href="?&sort_dir=asc">ascending</a>
</li>
---
<li class="disabled">
<a href="?&sort_dir=desc">descending</a>
</li>
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_options.metadata
0 → 100644
View file @
1d5b60d3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_title_asc.content
0 → 100644
View file @
1d5b60d3
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_title_asc.metadata
0 → 100644
View file @
1d5b60d3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_title_desc.content
0 → 100644
View file @
1d5b60d3
<h4 class="text-center">Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)</h4>
\ No newline at end of file
memopol/tests/response_fixtures/DossierListTest.test_navbar_order_title_desc.metadata
0 → 100644
View file @
1d5b60d3
{
"status_code": 200
}
\ No newline at end of file
memopol/tests/test_dossier_list.py
0 → 100644
View file @
1d5b60d3
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
)
memopol/views/dossier_list.py
View file @
1d5b60d3
...
...
@@ -14,21 +14,19 @@ class DossierList(PaginationMixin, SortMixin, generic.ListView):
current_filter
=
None
queryset
=
Dossier
.
objects
.
prefetch_related
(
'proposals'
,
'proposals__recommendation'
,
'documents'
,
'documents__chamber'
'documents__chamber'
,
'themes'
).
annotate
(
nb_proposals
=
Count
(
'proposals'
),
nb_recomm
=
Count
(
'proposals__recommendation'
)
nb_proposals
=
Count
(
'proposals'
,
distinct
=
True
),
nb_recommendations
=
Count
(
'proposals__recommendation'
,
distinct
=
True
),
nb_documents
=
Count
(
'documents'
,
distinct
=
True
)
)
sort_fields
=
{
'title'
:
'title'
,
'reference'
:
'reference'
,
'nb_recomm'
:
'recommendations'
,
'nb_recommendations'
:
'recommendations'
,
'nb_proposals'
:
'proposals'
,
}
sort_default_field
=
'nb_recomm'
sort_default_field
=
'nb_recomm
endations
'
sort_default_dir
=
'desc'
def
dossier_filter
(
self
,
qs
):
...
...
static/css/custom.css
View file @
1d5b60d3
...
...
@@ -22,12 +22,19 @@ body {
margin-top
:
1em
;
}
.tag
{
border
:
1px
solid
#487ed6
;
color
:
#487ed6
;
padding
:
.2em
.6em
;
border-radius
:
.25em
;
}
/***************************************************************
Typographie
***************************************************************/
@font-face
{
font-family
:
Propaganda
;
font-family
:
Propaganda
,
fixed
;
src
:
url(../fonts/PROPAGAN.ttf)
;
}
...
...
@@ -36,7 +43,7 @@ body, .panel-title {
}
h1
,
h2
,
h3
,
h4
,
h5
,
h6
{
font-family
:
Propaganda
;
font-family
:
Propaganda
,
fixed
;
}
h1
{
...
...
@@ -344,6 +351,7 @@ iframe {
width
:
1.75em
;
height
:
1.75em
;
line-height
:
initial
;
vertical-align
:
bottom
;
}
.flag-icon
:before
{
...
...
templates/representatives_votes/dossier_list.html
View file @
1d5b60d3
{% extends "base.html" %}
{% load bootstrap3 %}
{% load i18n %}
{% load memopol_tags %}
{% load humanize %}
{% block title %}{% trans "Doss
s
iers" %}{% endblock %}
{% 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 }} dossier
{% endblocktrans %}{% if search %}{% blocktrans %}on {{ search }}
{% endblocktrans
%}{% endif
%}.
{% blocktrans count counter=paginator.count %}{{ counter }} dossier{% plural %}{{ counter }} dossier
s
{% endblocktrans %}.
</p>
{% comment %}
<!-- TODO: ordering -->
<br/>
<p>
<div
class=
"dropdown"
style=
"display:inline-block;"
>
Order by
<button
class=
"btn btn-default dropdown-toggle"
type=
"button"
id=
"orderby"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"true"
>
Name
<span
class=
"caret"
></span>
</button>
<ul
class=
"dropdown-menu"
aria-labelledby=
"orderby"
>
<li
class=
"disabled"
><a
href=
"#"
>
Name
</a></li>
<li><a
href=
"#"
>
Recent
</a></li>
</ul>
</div>
</p>
{% endcomment %}
<div
class=
"col-xs-12 col-md-4"
>
{% for dossier in object_list %}
<div
class=
"thumbnail"
>
<a
href=
"{{ dossier.get_absolute_url }}"
class=
"custom-thumbnail custom-invisible"
>
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
<h4
class=
"text-center"
>
{{ dossier.title }}
</h4>
<p
class=
"text-center"
>
{% trans "Last updated" %} {{ dossier.updated|naturalday }}
</p>
<p
class=
"text-center lead"
>
{% comment %}
<!-- We don't have this data -->
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"Upcoming envents"
><span
class=
"glyphicon glyphicon-calendar"
></span>
<span
class=
"badge"
>
5
</span>
</span>
{% endcomment %}
<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>
</span>
{% comment %}
<!-- We don't have this data -->
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"Public positions"
><span
class=
"glyphicon glyphicon-comment"
></span>
<span
class=
"badge"
>
42
</span>
</span>
{% endcomment %}
</p>
{% comment %}
<!-- TODO -->
<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>
{% endcomment %}
</div>
</div>
</a>
</div>
{% include "blocks/listheader.html" %}
<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"
>
<div
class=
"col-xs-12"
>
<h4
class=
"text-center"
>
{{ dossier.title }}
</h4>
<p
class=
"text-center lead"
>
{% if dossier.nb_proposals > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Proposals' %}"
>
{% bootstrap_icon "file" %}
<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 %}
</p>
<p
class=
"text-center"
>
{% for chamber in dossier.chambers %}
{{ chamber|chamber_icon }}
{% endfor %}
{% for theme in dossier.themes.all %}
<span
class=
"tag"
>
{{ theme.name }}
</span>
{% endfor %}
{% if forloop.counter|divisibleby:3 %}
</div><div
class=
"col-xs-12 col-md-4"
>
{% endif %}
{% endfor %}
</p>
</div>
</div>
</a>
</div>
</div>
{% endfor %}
</div>
{% include "blocks/
_pagination
.html" %}
{% include "blocks/
listfooter
.html" %}
{% endblock %}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment