mysociety / yournextrepresentative

A website for crowd-sourcing structured election candidate data
https://candidates.democracyclub.org.uk/
GNU Affero General Public License v3.0
56 stars 21 forks source link

Display the party list position on the person page #906

Closed struan closed 8 years ago

struan commented 8 years ago

If a candidate has a party list position in an election this displays that alongside the candidacy in the Candidacies section of the person page.

Fixes #866

wfdd commented 8 years ago

This is gonna float below the text if it can't all fit on the same line.

screen shot 2016-05-06 at 17 02 16

You could try this instead:

diff --git a/candidates/static/candidates/_people.scss b/candidates/static/candidates/_people.scss
index 0824b91..1bb042d 100644
--- a/candidates/static/candidates/_people.scss
+++ b/candidates/static/candidates/_people.scss
@@ -19,6 +19,16 @@
   border-bottom: 1px solid #ccc;
 }

+%person-position {
+  line-height: (4em / 2);
+  height: (4em / 2);
+  width: (4em / 2);
+  text-align: center;
+  font-weight: bold;
+  background-color: $candidate-order-background-color;
+  color: $candidate-order-color;
+}
+
 // You can apply this class to a <dl> element to stack the
 // <dt> children vertically, with the <dd>s to one side.
 .key-value-list {
@@ -73,16 +83,10 @@
   @include clearfix;

   .person-position {
-    display: block;
+    @extend %person-position;
     float: left;
-    font-size: 1em * 2;
-    line-height: (4em / 2);
-    width: (4em / 2);
     margin-right: (1.5em / 2);
-    text-align: center;
-    font-weight: bold;
-    background-color: $candidate-order-background-color;
-    color: $candidate-order-color;
+    font-size: 1em * 2;
   }

   .person-avatar {
@@ -363,17 +367,19 @@
     }
   }

+  .person-candidacies {
+    position: relative;
+    padding-right: 2.5em;
+  }
+
   .person-position {
-    display: block;
-    float: right;
-    font-size: 1em;
-    line-height: (4em / 2);
-    width: (4em / 2);
-    margin-left: (1.5em / 2);
-    text-align: center;
-    font-weight: bold;
-    background-color: $candidate-order-background-color;
-    color: $candidate-order-color;
+    @extend %person-position;
+    position: absolute;
+    right: 0;
+    top: 0;
+    bottom: 0;
+    margin-top: auto;
+    margin-bottom: auto;
   }
 }

diff --git a/candidates/templatetags/standing.py b/candidates/templatetags/standing.py
index dcc3134..67da884 100644
--- a/candidates/templatetags/standing.py
+++ b/candidates/templatetags/standing.py
@@ -57,7 +57,7 @@ def post_in_election(person, election):
                 result = '<span class="constituency-value-unknown">%s</span>' % _('No information yet')
             else:
                 result = '<span class="constituency-not-standing">%s</span>' % _('Did not stand')
-    return mark_safe(result)
+    return mark_safe('<div class="person-candidacies">' + result + '</div>')

 @register.filter
 def election_decision_known(person, election):

screen-shot-2016-05-06-at-17 16 03

struan commented 8 years ago

I wonder if adding this on the left as it is elsewhere is actually the path of least resistance and consistency. It does mean things won't line up but probably helps draw attention to the number.

wfdd commented 8 years ago

The other issue with doing it this way is the badge and the text are neither on the same baseline nor vertically centred. But I'm probably nitpicking...

wfdd commented 8 years ago

Just making a note that this fixes #886 and not #866.