diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist/content index 67cb48d87d85ffec2e2b9861ba4d31fc23837e82..3506bfbbc4e514aa17043e1e0d2ebdf040096244 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist/content @@ -69,7 +69,7 @@ </li> <li> <a href='/votes/dossier/'> - Votes + Dossiers </a> </li> diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist_searchjoly/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist_searchjoly/content index 3e96d141906c1c12f8ad4e44126a6287890d5990..9daa5bb9a7581e1996bd1d15d4db530b40d2fe4f 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist_searchjoly/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist_searchjoly/content @@ -69,7 +69,7 @@ </li> <li> <a href='/votes/dossier/'> - Votes + Dossiers </a> </li> diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby24_displaygrid/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby24_displaygrid/content index 788d295dbbe65a2b338e98a18ba437a0b08b3e6e..e9bc516136ed72fa83bfd86dc62a3271c9c8272a 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby24_displaygrid/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby24_displaygrid/content @@ -69,7 +69,7 @@ </li> <li> <a href='/votes/dossier/'> - Votes + Dossiers </a> </li> diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby12_displaylist/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby12_displaylist/content index fbb2b4a8eeb275507d1a45242380901de4db14ad..211f4a3cd5495afc116d35c64dc8d5ee653db9ff 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby12_displaylist/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby12_displaylist/content @@ -69,7 +69,7 @@ </li> <li> <a href='/votes/dossier/'> - Votes + Dossiers </a> </li> diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby24_displaylist/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby24_displaylist/content index f0e6eca85aa18d4ab8b8e3b2b7dee09b8b99fdd2..303c9580e9db9caaad56921417ddde0f05f36f17 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby24_displaylist/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby24_displaylist/content @@ -69,7 +69,7 @@ </li> <li> <a href='/votes/dossier/'> - Votes + Dossiers </a> </li> diff --git a/memopol/views.py b/memopol/views.py index fb7ab10a090264685448591b0af087934bfeec0d..a3f1e8da23544e01d6197cf2c6e041d2232ab944 100644 --- a/memopol/views.py +++ b/memopol/views.py @@ -1,5 +1,6 @@ # Project specific "glue" coupling of all apps from django.db import models +from django.db.models import Count from core.views import GridListMixin, PaginationMixin, CSVDownloadMixin from representatives import views as representatives_views @@ -82,4 +83,9 @@ class RepresentativeDetail(representatives_views.RepresentativeDetail): class DossierList(PaginationMixin, representatives_votes_views.DossierList): - queryset = Dossier.objects.exclude(proposals__recommendation=None) + queryset = Dossier.objects.prefetch_related( + 'proposals', + 'proposals__recommendation' + ).annotate( + nb_recomm=Count('proposals__recommendation') + ).order_by('-nb_recomm', '-reference') diff --git a/templates/_header.haml b/templates/_header.haml index a1670f4a5482709e9dbedf9f4f805d79e564c1df..b0dd05f50be6b3e5312f7b7f1773c39a8ec85b55 100644 --- a/templates/_header.haml +++ b/templates/_header.haml @@ -34,4 +34,4 @@ - trans 'Committees' %li %a{href: "{% url 'representatives_votes:dossier-list' %}"} - - trans 'Votes' + - trans 'Dossiers' diff --git a/templates/representatives_votes/dossier_detail.haml b/templates/representatives_votes/dossier_detail.haml index 2237b973bd3bd0fd7d9cf25059e472cee5d32f6b..2734ac692666ddc4bcd7162eacd8603856fcfa34 100644 --- a/templates/representatives_votes/dossier_detail.haml +++ b/templates/representatives_votes/dossier_detail.haml @@ -1,32 +1,43 @@ - extends "base.html" +- load i18n +- load representatives_votes_tags + - block content - %h2= dossier.name - %h3= dossier.title + %h1 {{ dossier.name }} {{ dossier.title }} %p <strong>{{ dossier.reference }}</strong> - %h3 Votes ({{dossier.proposals.count}}) - - for proposal in dossier.proposals.all - %h4 - {{ forloop.counter }}. - {{ proposal.recommendation.title }} - - {{ proposal.datetime }} - - {{ proposal.status }} - %p - {{ proposal.title }} - %small - {{ proposal.reference }} - {{ proposal.kind }} - {{ proposal.recommendation.description }} - %p - %h5 - For : {{ proposal.total_for }} - %h5 - Against : {{ proposal.total_against }} - %h5 - Abstain : {{ proposal.total_abstain }} - %p - Participants : {{ proposal.representatives.count }} - + %h2 + - trans "Recommendations" + + %table.table + %tr + %th + - trans "Proposal" + %th + - trans "Title" + %th + - trans "Recommendation" + %th + - trans "Status" + %th= "for" | position_icon + %th= "against" | position_icon + %th= "abstain" | position_icon + + - for proposal in dossier.proposals.all + %tr + %td + = proposal.title + %br + %small + {{ proposal.reference }} + {{ proposal.kind }} + %td= proposal.recommendation.title + %td= proposal.recommendation.recommendation | position_icon + %td= proposal.status + %td= proposal.total_for + %td= proposal.total_against + %td= proposal.total_abstain + diff --git a/templates/representatives_votes/dossier_list.haml b/templates/representatives_votes/dossier_list.haml index 2f3e2cc616727c33ee4c2304be91042af054402d..15d1bab16e7fd11dfc5fd64a433507e98c4d2224 100644 --- a/templates/representatives_votes/dossier_list.haml +++ b/templates/representatives_votes/dossier_list.haml @@ -1,14 +1,25 @@ - extends "base.html" +- load i18n - block content - %h1 Dossiers + %h1 + - trans "Dossiers" %table.table + %tr + %th + - trans "Title" + %th + - trans "Recommendations" + %th + - trans "Reference" + - for dossier in object_list %tr %td %a{'href': "{{ dossier.get_absolute_url }}"} {{ dossier.title }} + %td= dossier.nb_recomm %td= dossier.reference - include "core/blocks/pagination.html"