Commit 5666f0ba authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Add theme tags to dossiers in rep votes page

parent d0cbef85
<a aria-controls="dossier-15424" aria-expanded="false" data-parent="#accordion-dossier" data-toggle="collapse" href="#dossier-15424" role="button"> <a aria-controls="dossier-15424" aria-expanded="false" data-parent="#accordion-dossier" data-toggle="collapse" href="#dossier-15424" role="button">
Pouvoirs publics : application de la loi relative à l’état d’urgence Pouvoirs publics : application de la loi relative à l’état d’urgence
<span class="pull-right">
<span class="badge badge-danger" data-placement="left" data-toggle="tooltip" title="Score for the representative on this specific dossier">-100</span>
</span>
</a> </a>
--- ---
<a aria-controls="dossier-15409" aria-expanded="false" data-parent="#accordion-dossier" data-toggle="collapse" href="#dossier-15409" role="button"> <a aria-controls="dossier-15409" aria-expanded="false" data-parent="#accordion-dossier" data-toggle="collapse" href="#dossier-15409" role="button">
Pouvoirs publics : prorogation de l'application de la loi sur l'état d'urgence Pouvoirs publics : prorogation de l'application de la loi sur l'état d'urgence
<span class="pull-right">
<span class="badge badge-success" data-placement="left" data-toggle="tooltip" title="Score for the representative on this specific dossier">75</span>
</span>
</a> </a>
--- ---
<a aria-controls="dossier-15407" aria-expanded="false" data-parent="#accordion-dossier" data-toggle="collapse" href="#dossier-15407" role="button"> <a aria-controls="dossier-15407" aria-expanded="false" data-parent="#accordion-dossier" data-toggle="collapse" href="#dossier-15407" role="button">
Pouvoirs publics : prorogation de l'état d'urgence Pouvoirs publics : prorogation de l'état d'urgence
<span class="pull-right">
<span class="badge badge-danger" data-placement="left" data-toggle="tooltip" title="Score for the representative on this specific dossier">-90</span>
</span>
</a> </a>
\ No newline at end of file
...@@ -7,8 +7,9 @@ class RepresentativeVotesTest(RepresentativeBaseTest): ...@@ -7,8 +7,9 @@ class RepresentativeVotesTest(RepresentativeBaseTest):
""" """
- One for votes - One for votes
- One for dossier scores - One for dossier scores
- Two for dossier themes (?? should be one according to the queryset !)
""" """
queries = RepresentativeBaseTest.queries + 2 queries = RepresentativeBaseTest.queries + 4
def test_queries(self): def test_queries(self):
self.do_query_test() self.do_query_test()
......
...@@ -22,6 +22,8 @@ class RepresentativeDetailVotes(RepresentativeDetailBase): ...@@ -22,6 +22,8 @@ class RepresentativeDetailVotes(RepresentativeDetailBase):
'vote_score', 'vote_score',
'proposal__dossier', 'proposal__dossier',
'proposal__recommendation' 'proposal__recommendation'
).prefetch_related(
'proposal__dossier__themes'
).order_by('-proposal__datetime', 'proposal__title') ).order_by('-proposal__datetime', 'proposal__title')
), ),
'dossier_scores' 'dossier_scores'
...@@ -39,10 +41,11 @@ class RepresentativeDetailVotes(RepresentativeDetailBase): ...@@ -39,10 +41,11 @@ class RepresentativeDetailVotes(RepresentativeDetailBase):
dossier = vote.proposal.dossier dossier = vote.proposal.dossier
pk = dossier.pk pk = dossier.pk
if pk not in dossiers: if pk not in dossiers:
scores = [s.score for s in ds if s.dossier_id == pk]
dossiers[pk] = { dossiers[pk] = {
'dossier': dossier, 'dossier': dossier,
'votes': [], 'votes': [],
'score': [s.score for s in ds if s.dossier_id == pk][0] 'score': scores[0] if len(scores) else 0
} }
dossiers[pk]['votes'].append(vote) dossiers[pk]['votes'].append(vote)
......
...@@ -387,6 +387,13 @@ iframe { ...@@ -387,6 +387,13 @@ iframe {
margin-bottom: 5px; margin-bottom: 5px;
} }
#accordion-dossier h4.panel-title {
display: inline;
}
#accordion-dossier .panel-heading .badge {
margin-left: 1em;
}
/*************************************************************** /***************************************************************
Icones Icones
......
...@@ -22,12 +22,14 @@ ...@@ -22,12 +22,14 @@
<h4 class="panel-title"> <h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion-dossier" href="#dossier-{{ pk }}" aria-expanded="false" aria-controls="dossier-{{ pk }}"> <a role="button" data-toggle="collapse" data-parent="#accordion-dossier" href="#dossier-{{ pk }}" aria-expanded="false" aria-controls="dossier-{{ pk }}">
{{ dossier.title }} {{ dossier.title }}
<span class="pull-right">
{% trans "Score for the representative on this specific dossier" as tooltip %}
{{ d.score|score_badge:tooltip }}
</span>
</a> </a>
</h4> </h4>
<span class="pull-right">
{% include "blocks/_themetags.html" with themes=dossier.themes.all %}
{% trans "Score for the representative on this specific dossier" as tooltip %}
{{ d.score|score_badge:tooltip }}
</span>
</div> </div>
<div id="dossier-{{ pk }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="dossier-heading-{{ pk }}"> <div id="dossier-{{ pk }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="dossier-heading-{{ pk }}">
<div class="panel-body"> <div class="panel-body">
......
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