From 15092de4167f99041518f20c1d87a839bec79aad Mon Sep 17 00:00:00 2001 From: turbobilly Date: Mon, 20 May 2013 14:47:31 +0200 Subject: [PATCH 01/10] Have average results box behave well with pagination --- memopol/base/templates/blocks/representative_list.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/memopol/base/templates/blocks/representative_list.haml b/memopol/base/templates/blocks/representative_list.haml index d84527df..0b321884 100644 --- a/memopol/base/templates/blocks/representative_list.haml +++ b/memopol/base/templates/blocks/representative_list.haml @@ -4,6 +4,8 @@ -if per_page > 0 -# Note that "paginate" doesn't accept variable name with dot inside -paginate per_page objects + -if not endless.paginated or endless.page.number == 1 + -include "blocks/representative_list_average.html" with average=dynamiq.average -for result in objects -include "blocks/representative_list_item.html" with result_mep=result -if per_page > 0 From 98c652fabe012a1ed7dbfd70cba863fd81e617bc Mon Sep 17 00:00:00 2001 From: turbobilly Date: Mon, 20 May 2013 22:07:09 +0200 Subject: [PATCH 02/10] [enh] add microdata attributes. fixes #404 --- memopol/meps/templates/meps/mep_detail.haml | 3 +-- .../meps/templates/meps/mep_detail/main.haml | 22 +++++++++++-------- .../templates/meps/mep_detail/scores.haml | 15 ++++++++----- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/memopol/meps/templates/meps/mep_detail.haml b/memopol/meps/templates/meps/mep_detail.haml index 71379469..25f25124 100644 --- a/memopol/meps/templates/meps/mep_detail.haml +++ b/memopol/meps/templates/meps/mep_detail.haml @@ -5,8 +5,7 @@ -block content .row - .twelve.columns - + .twelve.columns{itemscope: None, itemtype: "http://schema.org/Product"} %dl.tabs %dd.active %a{href: "#profile"} diff --git a/memopol/meps/templates/meps/mep_detail/main.haml b/memopol/meps/templates/meps/mep_detail/main.haml index 637abff3..181340fb 100644 --- a/memopol/meps/templates/meps/mep_detail/main.haml +++ b/memopol/meps/templates/meps/mep_detail/main.haml @@ -3,14 +3,18 @@ .twelve.columns.floor .row.panel .two.columns - %img{width: "100px", src: "{% url meps:mep-picture mep.ep_id %}"} + %img{width: "100px", src: "{% url meps:mep-picture mep.ep_id %}", itemprop: "image"} - .two.columns - %div{class: "panel radius {{ mep.total_score|scolorize }}"} + .two.columns{itemscope: None, itemtype: "http://schema.org/AggregateRating", itemprop: "aggregateRating"} + %div{class: "panel radius {{ mep.total_score|scolorize }}", itemprop: "ratingValue"} =mep.total_score|floatformat:1 + + + + .six.columns - %h4 + %h4{itemprop: "name"} =mep %div -for achievement in mep.achievements.all @@ -30,13 +34,13 @@ -trans "Former mep" %li %a{href: "{% url meps:index_by_country mep.country.code %}"} - %span{class: "sprite-country_small-{{ mep.country.code }}"} - =mep.country.name + %span{class: "sprite-country_small-{{ mep.country.code }}", itemprop: "brand"} + =mep.country.name -if mep.group %li %a{href: "{% url meps:index_by_group mep.group.abbreviation %}"} - %span{class: "sprite-eu_group-{{ mep.group.abbreviation|cut:'/' }}"} - {{ mep.group.name }} ({{ mep.group.abbreviation }}) + %span{class: "sprite-eu_group-{{ mep.group.abbreviation|cut:'/' }}", itemprop: "brand"} + {{ mep.group.name }} ({{ mep.group.abbreviation }}) %ul.eight.columns -for post in mep.important_posts @@ -45,7 +49,7 @@ {{ post.role }} of {{ post.instance.name }} -if mep.party %li - {% trans "National party" %}: {{ mep.party.name }} + {% trans "National party" %}: {{ mep.party.name }} -if mep.birth_date %li {% if mep.gender == 'M' %}{% trans "Born on" %}{% else %}{% trans "Born on (female)" %}{% endif %} {% blocktrans with mep.birth_date.day as day and mep.birth_date|date:'F' as month and mep.birth_date.year as year and mep.birth_place as birth_place and mep.age as age %}{{ day }} {{ month }} {{ year }} at {{ birth_place }}, {{ age }} years old.{% endblocktrans %} diff --git a/memopol/meps/templates/meps/mep_detail/scores.haml b/memopol/meps/templates/meps/mep_detail/scores.haml index e0292656..69f25a9f 100644 --- a/memopol/meps/templates/meps/mep_detail/scores.haml +++ b/memopol/meps/templates/meps/mep_detail/scores.haml @@ -11,14 +11,19 @@ -trans "Trends explanation" -for score in mep.scores - .row.panel + .row.panel{itemprop: "review", itemscope: None, itemtype: "http://schema.org/Review"} .two.columns - %div{class: "panel radius {{ score.value|scolorize }}"} - =score.value|floatformat:1 + %div{class: "panel radius {{ score.value|scolorize }}", itemprop: "reviewRating", itemscope: None, itemtype: "http://schema.org/Rating"} + %span{itemprop: "ratingValue"} + =score.value|floatformat:1 + %span{itemprop: "worstRating", content: "0"} + %span{itemprop: "bestRating", content: "100"} .eight.columns - {{ score.proposal.title }} {% blocktrans with score.date as score_date %}(on {{ score_date }}){% endblocktrans %} + + {{ score.proposal.title }} {% blocktrans with score.date as score_date %}(on {{ score_date }}){% endblocktrans %} - .two.columns + .two.columns{itemprop: "reviewBody"} %a.button.secondary{href: "{% url meps:votes:votes_mep score.proposal.id mep.id %}"} -trans "Details" + %meta{itemprop: "author", content: "LQDN"} From ee246cb9c77c85102f1a49078c168931a6fefdaa Mon Sep 17 00:00:00 2001 From: turbobilly Date: Thu, 23 May 2013 15:35:11 +0200 Subject: [PATCH 03/10] add microdata to search results page --- .../blocks/representative_list_item.haml | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/memopol/base/templates/blocks/representative_list_item.haml b/memopol/base/templates/blocks/representative_list_item.haml index 9ac7ac89..6a120fe2 100644 --- a/memopol/base/templates/blocks/representative_list_item.haml +++ b/memopol/base/templates/blocks/representative_list_item.haml @@ -2,13 +2,26 @@ -cache 86400 representative_list_item result_mep.id -with mep=result_mep.object - .floor.twelve.list_item - .row.panel + .floor.twelve.list_item{itemscope: None, itemtype: "http://schema.org/Review"} + %div{itemscope: None, itemtype: "http://schema.org/AggregateRating", + itemprop: "aggregateRating", style: "display: none;"} + {{ mep.total_score|floatformat:1 }} + {{ mep.score_set.all|length }} + 100 + 0 + .row.panel{itemscope: None, itemtype: "http://schema.org/Person", + itemprop: "itemReviewed"} + %div{style: "display: none;"} + %div{itemprop="nationality"} + {{ mep.country.name }} + -for group in mep.groups.all + -# we should do the same with organizations, delegations, etc... + {{ group.name }} .four.columns.flat.mobile-four .five.columns.flat.mobile-two %a{class: "th", href: "{{ mep.get_absolute_url }}"} - %img{width: "100px", src: "{% url meps:mep-picture mep.ep_id %}"} - + %img{width: "100px", src: "{% url meps:mep-picture mep.ep_id %}", + itemprop: "image"} .seven.columns.mobile-two .panel.radius{class: "{{ mep.total_score|scolorize }}"} =mep.total_score|floatformat:1 @@ -20,7 +33,8 @@ .six.columns .row %h4 - %a{href: "{{ mep.get_absolute_url }}", style: "color: black;"} + %a{href: "{{ mep.get_absolute_url }}", style: "color: black;", + itemprop: "name"} =mep .row -for achievement in mep.achievements.all @@ -32,7 +46,6 @@ {{ post.instance.name }} -if not post.role|lower == "member" ({{ post.role|lower }}) - .two.columns.mobile-four -if mep.active and mep.bxl_phone1 -call_now mep.bxl_phone1 From 5b1aba5984c3dc5b125cfadc0aa7ab66dee99937 Mon Sep 17 00:00:00 2001 From: okhin Date: Sun, 19 May 2013 18:32:49 +0200 Subject: [PATCH 04/10] Bug #320 - Add the average score to the search result page --- memopol/base/templates/blocks/representative_list.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/memopol/base/templates/blocks/representative_list.haml b/memopol/base/templates/blocks/representative_list.haml index 0b321884..a5185bba 100644 --- a/memopol/base/templates/blocks/representative_list.haml +++ b/memopol/base/templates/blocks/representative_list.haml @@ -1,5 +1,7 @@ -load endless +-if dynamiq.average > 0 + -include "blocks/representative_list_average.html" with average=dynamiq.average -with objects=dynamiq.results -if per_page > 0 -# Note that "paginate" doesn't accept variable name with dot inside From 7a41ef99fafb078296564a53f8ca4ae836e52b3c Mon Sep 17 00:00:00 2001 From: turbobilly Date: Mon, 20 May 2013 14:47:31 +0200 Subject: [PATCH 05/10] Have average results box behave well with pagination --- memopol/base/templates/blocks/representative_list.haml | 2 -- 1 file changed, 2 deletions(-) diff --git a/memopol/base/templates/blocks/representative_list.haml b/memopol/base/templates/blocks/representative_list.haml index a5185bba..0b321884 100644 --- a/memopol/base/templates/blocks/representative_list.haml +++ b/memopol/base/templates/blocks/representative_list.haml @@ -1,7 +1,5 @@ -load endless --if dynamiq.average > 0 - -include "blocks/representative_list_average.html" with average=dynamiq.average -with objects=dynamiq.results -if per_page > 0 -# Note that "paginate" doesn't accept variable name with dot inside From f8d1acce7ffffd226e7148ca9007190d38e9f2ef Mon Sep 17 00:00:00 2001 From: turbobilly Date: Thu, 23 May 2013 15:35:11 +0200 Subject: [PATCH 06/10] add microdata to search results page --- memopol/base/templates/blocks/representative_list_item.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/memopol/base/templates/blocks/representative_list_item.haml b/memopol/base/templates/blocks/representative_list_item.haml index 6a120fe2..bb3e40b2 100644 --- a/memopol/base/templates/blocks/representative_list_item.haml +++ b/memopol/base/templates/blocks/representative_list_item.haml @@ -29,7 +29,6 @@ =mep.country_tag|safe %div =mep.group_tag|safe - .six.columns .row %h4 From 4643f0d12c166cccf043a7c72604cd6edc710862 Mon Sep 17 00:00:00 2001 From: okhin Date: Sun, 19 May 2013 18:32:49 +0200 Subject: [PATCH 07/10] Bug #320 - Add the average score to the search result page --- memopol/search/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/memopol/search/views.py b/memopol/search/views.py index 2598dd09..0c00f510 100644 --- a/memopol/search/views.py +++ b/memopol/search/views.py @@ -79,7 +79,11 @@ def get_context_data(self, **kwargs): "label": label, "formset": formset, "form": form, +<<<<<<< HEAD "average": average, +======= + "average": average, +>>>>>>> Bug #320 - Add the average score to the search result page "shortcuts": [ TopRated({"request": self.request}), WorstRated({"request": self.request}) From e0ff53e6a22c44410b6a5ad270f1b8a9ec6558fa Mon Sep 17 00:00:00 2001 From: turbobilly Date: Mon, 20 May 2013 14:47:31 +0200 Subject: [PATCH 08/10] Cleanups --- .../base/templates/blocks/representative_list.haml | 2 -- .../templates/blocks/representative_list_item.haml | 7 +++++-- memopol/meps/templates/meps/mep_detail.haml | 1 + memopol/meps/templates/meps/mep_detail/main.haml | 11 ++++++----- memopol/meps/templates/meps/mep_detail/scores.haml | 12 ++++++++---- memopol/search/views.py | 4 ---- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/memopol/base/templates/blocks/representative_list.haml b/memopol/base/templates/blocks/representative_list.haml index 0b321884..d84527df 100644 --- a/memopol/base/templates/blocks/representative_list.haml +++ b/memopol/base/templates/blocks/representative_list.haml @@ -4,8 +4,6 @@ -if per_page > 0 -# Note that "paginate" doesn't accept variable name with dot inside -paginate per_page objects - -if not endless.paginated or endless.page.number == 1 - -include "blocks/representative_list_average.html" with average=dynamiq.average -for result in objects -include "blocks/representative_list_item.html" with result_mep=result -if per_page > 0 diff --git a/memopol/base/templates/blocks/representative_list_item.haml b/memopol/base/templates/blocks/representative_list_item.haml index bb3e40b2..c0fb57f5 100644 --- a/memopol/base/templates/blocks/representative_list_item.haml +++ b/memopol/base/templates/blocks/representative_list_item.haml @@ -12,8 +12,8 @@ .row.panel{itemscope: None, itemtype: "http://schema.org/Person", itemprop: "itemReviewed"} %div{style: "display: none;"} - %div{itemprop="nationality"} - {{ mep.country.name }} + %div{itemprop: "nationality"} + =mep.country.name -for group in mep.groups.all -# we should do the same with organizations, delegations, etc... {{ group.name }} @@ -22,6 +22,7 @@ %a{class: "th", href: "{{ mep.get_absolute_url }}"} %img{width: "100px", src: "{% url meps:mep-picture mep.ep_id %}", itemprop: "image"} + .seven.columns.mobile-two .panel.radius{class: "{{ mep.total_score|scolorize }}"} =mep.total_score|floatformat:1 @@ -29,6 +30,7 @@ =mep.country_tag|safe %div =mep.group_tag|safe + .six.columns .row %h4 @@ -45,6 +47,7 @@ {{ post.instance.name }} -if not post.role|lower == "member" ({{ post.role|lower }}) + .two.columns.mobile-four -if mep.active and mep.bxl_phone1 -call_now mep.bxl_phone1 diff --git a/memopol/meps/templates/meps/mep_detail.haml b/memopol/meps/templates/meps/mep_detail.haml index 25f25124..69b86bfa 100644 --- a/memopol/meps/templates/meps/mep_detail.haml +++ b/memopol/meps/templates/meps/mep_detail.haml @@ -6,6 +6,7 @@ -block content .row .twelve.columns{itemscope: None, itemtype: "http://schema.org/Product"} + %dl.tabs %dd.active %a{href: "#profile"} diff --git a/memopol/meps/templates/meps/mep_detail/main.haml b/memopol/meps/templates/meps/mep_detail/main.haml index 181340fb..1be17c1f 100644 --- a/memopol/meps/templates/meps/mep_detail/main.haml +++ b/memopol/meps/templates/meps/mep_detail/main.haml @@ -8,10 +8,11 @@ .two.columns{itemscope: None, itemtype: "http://schema.org/AggregateRating", itemprop: "aggregateRating"} %div{class: "panel radius {{ mep.total_score|scolorize }}", itemprop: "ratingValue"} =mep.total_score|floatformat:1 - - - - + %div{style: "display: none;"} + {{ mep }} + {{ mep.scores|length }} + 100 + 0 .six.columns %h4{itemprop: "name"} @@ -49,7 +50,7 @@ {{ post.role }} of {{ post.instance.name }} -if mep.party %li - {% trans "National party" %}: {{ mep.party.name }} + {% trans "National party" %}: {{ mep.party.name }} -if mep.birth_date %li {% if mep.gender == 'M' %}{% trans "Born on" %}{% else %}{% trans "Born on (female)" %}{% endif %} {% blocktrans with mep.birth_date.day as day and mep.birth_date|date:'F' as month and mep.birth_date.year as year and mep.birth_place as birth_place and mep.age as age %}{{ day }} {{ month }} {{ year }} at {{ birth_place }}, {{ age }} years old.{% endblocktrans %} diff --git a/memopol/meps/templates/meps/mep_detail/scores.haml b/memopol/meps/templates/meps/mep_detail/scores.haml index 69f25a9f..11eca7b0 100644 --- a/memopol/meps/templates/meps/mep_detail/scores.haml +++ b/memopol/meps/templates/meps/mep_detail/scores.haml @@ -16,14 +16,18 @@ %div{class: "panel radius {{ score.value|scolorize }}", itemprop: "reviewRating", itemscope: None, itemtype: "http://schema.org/Rating"} %span{itemprop: "ratingValue"} =score.value|floatformat:1 - %span{itemprop: "worstRating", content: "0"} - %span{itemprop: "bestRating", content: "100"} + %span{itemprop: "worstRating"} + 0 + %span{itemprop: "bestRating"} + 100 .eight.columns - + %div{itemprop: "datePublished", style: "display: none;"} + =score.date|date:"Y-m-d" {{ score.proposal.title }} {% blocktrans with score.date as score_date %}(on {{ score_date }}){% endblocktrans %} .two.columns{itemprop: "reviewBody"} %a.button.secondary{href: "{% url meps:votes:votes_mep score.proposal.id mep.id %}"} -trans "Details" - %meta{itemprop: "author", content: "LQDN"} + %div{itemprop: "author", style: "display: none;"} + lqdn diff --git a/memopol/search/views.py b/memopol/search/views.py index 0c00f510..2598dd09 100644 --- a/memopol/search/views.py +++ b/memopol/search/views.py @@ -79,11 +79,7 @@ def get_context_data(self, **kwargs): "label": label, "formset": formset, "form": form, -<<<<<<< HEAD "average": average, -======= - "average": average, ->>>>>>> Bug #320 - Add the average score to the search result page "shortcuts": [ TopRated({"request": self.request}), WorstRated({"request": self.request}) From 4d84e636d75345483055fbca1665398a2cb2b944 Mon Sep 17 00:00:00 2001 From: turbobilly Date: Sun, 26 May 2013 22:39:50 +0200 Subject: [PATCH 09/10] hamlize trailing html --- .../blocks/representative_list_item.haml | 18 ++++++++++++------ .../meps/templates/meps/mep_detail/main.haml | 12 ++++++++---- .../meps/templates/meps/mep_detail/scores.haml | 6 ++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/memopol/base/templates/blocks/representative_list_item.haml b/memopol/base/templates/blocks/representative_list_item.haml index c0fb57f5..9e439d68 100644 --- a/memopol/base/templates/blocks/representative_list_item.haml +++ b/memopol/base/templates/blocks/representative_list_item.haml @@ -5,10 +5,14 @@ .floor.twelve.list_item{itemscope: None, itemtype: "http://schema.org/Review"} %div{itemscope: None, itemtype: "http://schema.org/AggregateRating", itemprop: "aggregateRating", style: "display: none;"} - {{ mep.total_score|floatformat:1 }} - {{ mep.score_set.all|length }} - 100 - 0 + %span{itemprop: "ratingValue"} + =mep.total_score|floatformat:1 + %span{itemprop: "reviewCount"} + =mep.score_set.all|length + %span{itemprop: "bestRating"} + 100 + %span{itemprop: "worstRating"} + 0 .row.panel{itemscope: None, itemtype: "http://schema.org/Person", itemprop: "itemReviewed"} %div{style: "display: none;"} @@ -16,7 +20,8 @@ =mep.country.name -for group in mep.groups.all -# we should do the same with organizations, delegations, etc... - {{ group.name }} + %span{itemprop: "memberof"} + =group.name .four.columns.flat.mobile-four .five.columns.flat.mobile-two %a{class: "th", href: "{{ mep.get_absolute_url }}"} @@ -44,7 +49,8 @@ %ul -for post in mep.important_posts %li - {{ post.instance.name }} + %a{href: "{{ post.instance.get_absolute_url }}"} + =post.instance.name -if not post.role|lower == "member" ({{ post.role|lower }}) diff --git a/memopol/meps/templates/meps/mep_detail/main.haml b/memopol/meps/templates/meps/mep_detail/main.haml index 1be17c1f..9e09f633 100644 --- a/memopol/meps/templates/meps/mep_detail/main.haml +++ b/memopol/meps/templates/meps/mep_detail/main.haml @@ -9,10 +9,14 @@ %div{class: "panel radius {{ mep.total_score|scolorize }}", itemprop: "ratingValue"} =mep.total_score|floatformat:1 %div{style: "display: none;"} - {{ mep }} - {{ mep.scores|length }} - 100 - 0 + %span{itemprop: "itemReviewed"} + =mep + %span{itemprop: "ratingCount"} + =mep.scores|length + %span{itemprop: "bestRating"} + 100 + %span{itemprop: "worstRating"} + 0 .six.columns %h4{itemprop: "name"} diff --git a/memopol/meps/templates/meps/mep_detail/scores.haml b/memopol/meps/templates/meps/mep_detail/scores.haml index 11eca7b0..62348667 100644 --- a/memopol/meps/templates/meps/mep_detail/scores.haml +++ b/memopol/meps/templates/meps/mep_detail/scores.haml @@ -24,10 +24,12 @@ .eight.columns %div{itemprop: "datePublished", style: "display: none;"} =score.date|date:"Y-m-d" - {{ score.proposal.title }} {% blocktrans with score.date as score_date %}(on {{ score_date }}){% endblocktrans %} + %a{href: "{{ score.proposal.get_absolute_url }}", itemprop: "about"} + =score.proposal.title + {% blocktrans with score.date as score_date %}(on {{ score_date }}){% endblocktrans %} .two.columns{itemprop: "reviewBody"} %a.button.secondary{href: "{% url meps:votes:votes_mep score.proposal.id mep.id %}"} -trans "Details" %div{itemprop: "author", style: "display: none;"} - lqdn + La Quadrature du Net From defc567fcb76a688e204bfeabce0c04b83ca9924 Mon Sep 17 00:00:00 2001 From: turbobilly Date: Sun, 26 May 2013 22:48:41 +0200 Subject: [PATCH 10/10] fix small display issues --- memopol/meps/templates/meps/mep_detail/main.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/memopol/meps/templates/meps/mep_detail/main.haml b/memopol/meps/templates/meps/mep_detail/main.haml index 9e09f633..de1bc7f1 100644 --- a/memopol/meps/templates/meps/mep_detail/main.haml +++ b/memopol/meps/templates/meps/mep_detail/main.haml @@ -39,12 +39,14 @@ -trans "Former mep" %li %a{href: "{% url meps:index_by_country mep.country.code %}"} - %span{class: "sprite-country_small-{{ mep.country.code }}", itemprop: "brand"} + %span{class: "sprite-country_small-{{ mep.country.code }}"} + %span{itemprop: "brand"} =mep.country.name -if mep.group %li %a{href: "{% url meps:index_by_group mep.group.abbreviation %}"} - %span{class: "sprite-eu_group-{{ mep.group.abbreviation|cut:'/' }}", itemprop: "brand"} + %span{class: "sprite-eu_group-{{ mep.group.abbreviation|cut:'/' }}"} + %span{itemprop: "brand"} {{ mep.group.name }} ({{ mep.group.abbreviation }}) %ul.eight.columns