Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/new person page #660

Merged

Conversation

VirginiaDooley
Copy link
Contributor

@VirginiaDooley VirginiaDooley commented Feb 10, 2021

This work implements the new DC design system for the candidate (Person) page as well as addresses the following:
*Related issues:
* #211
* #599
* #202
* #198
* #404

To install the new DC design system as a python package and test the changes in this PR, follow these instructions.

Note on testing:

Some conditionals in the template require us to create new factories and we weren't sure those sections (such as CV) would be made live just yet. Once the invalid template setting PR is merged, which is dependent on the DC base theme, it will catch conditionals we haven't explicitly tested here.

New design system screenshots

Intro Card for candidate with more than one current candidacy

Screen Shot 2021-03-04 at 9 03 33 PM

Policies Card with expanded long (>100 words) statement to voters for long statements

Screen Shot 2021-03-04 at 9 03 48 PM

Shorter statement to voters

Screen Shot 2021-02-25 at 8 02 38 AM

About card (includes when present: wikipedia, CV, TWFY link)

Screen Shot 2021-02-24 at 11 02 04 AM

Contact card

Screen Shot 2021-03-04 at 9 05 34 PM

Previous elections Table

Screen Shot 2021-03-04 at 9 18 50 PM

@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch 2 times, most recently from c2ab970 to 7690876 Compare February 12, 2021 11:23
@coveralls
Copy link

coveralls commented Feb 12, 2021

Coverage Status

Coverage increased (+0.9%) to 51.923% when pulling 8f1672a on VirginiaDooley:feature/new-person-page into 6ae6c10 on DemocracyClub:master.

@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch 2 times, most recently from 07aa2d5 to 3a24525 Compare February 12, 2021 18:08
requirements/base.txt Outdated Show resolved Hide resolved
@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch from 16d2b69 to 67d9f95 Compare February 16, 2021 10:25
@michaeljcollinsuk
Copy link
Contributor

If you wanted a hand writing any unit tests for your model methods, I'd be happy to pair on it with you!

@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch 3 times, most recently from c690ad2 to b089459 Compare February 22, 2021 10:13
@VirginiaDooley VirginiaDooley marked this pull request as ready for review February 22, 2021 18:12
@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch from 18e1906 to da66f08 Compare February 23, 2021 17:27
wcivf/apps/people/models.py Outdated Show resolved Hide resolved
wcivf/assets/scss/main.scss Outdated Show resolved Hide resolved
wcivf/apps/people/templates/people/person_detail.html Outdated Show resolved Hide resolved
wcivf/apps/people/templates/people/person_detail.html Outdated Show resolved Hide resolved
@property
def facebook_personal_username(self):
facebook_personal_url = self.facebook_personal_url
facebook_split = list(filter(None, facebook_personal_url.split("/")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all these properties:

First, I wonder if there's a way to DRY up the methods a little - like pulling the main logic in to one place?

Second, parsing URLs is (or can be) hard - for example, we don't know that someone hadn't added a querystring to the end of a given URL that might look odd.

Here's an example from the actual data:

https://www.facebook.com/sarahmurraylibdem?notif_id=1523864067803194&notif_t=page_invite_accept&ref=notif.

I think this code would reduce this down to:

sarahmurraylibdem?notif_id=1523864067803194&notif_t=page_invite_accept&ref=notif.

A better option might be to use Python's build in URL parsing:

from urllib.parse import urlparse
parsed_url = urlparse('https://www.facebook.com/sarahmurraylibdem?notif_id=1523864067803194&notif_t=page_invite_accept&ref=notif')

Now parsed_url.path would be sarahmurraylibdem but might also contain more path elements, so we'd want to then do `url = parsed_url.path.split("/")[0].

Of course the real solution here is to get the screen name from the 3rd party site itself, but that's a problem for another day!

Copy link
Contributor Author

@VirginiaDooley VirginiaDooley Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. I'll put this on my 'things to refactor' list. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Punting this to an issue as suggested so we can get this reviewed and rolled out faster.

wcivf/apps/people/models.py Outdated Show resolved Hide resolved
wcivf/assets/scss/main.scss Outdated Show resolved Hide resolved
wcivf/apps/people/models.py Outdated Show resolved Hide resolved
wcivf/apps/parties/models.py Outdated Show resolved Hide resolved
wcivf/apps/people/templates/people/person_detail.html Outdated Show resolved Hide resolved
@VirginiaDooley VirginiaDooley changed the title WIP; Feature/new person page Feature/new person page Feb 24, 2021
wcivf/apps/people/models.py Outdated Show resolved Hide resolved
@symroe
Copy link
Member

symroe commented Feb 25, 2021

Happy with where this is now - feel free to punt the URL parsing to an issue - I'll leave that one up to you to decide 👍

@pmk01
Copy link
Contributor

pmk01 commented Feb 25, 2021

Just jumping in to say these look brilliant! My only thought is on the photo cropping, have you tested this with candidates who have a particularly low-res picture, or headshots in profile? This is a small number of images and will probably encourage us to find better photos, but thought I'd mention it.

@VirginiaDooley
Copy link
Contributor Author

Just jumping in to say these look brilliant! My only thought is on the photo cropping, have you tested this with candidates who have a particularly low-res picture, or headshots in profile? This is a small number of images and will probably encourage us to find better photos, but thought I'd mention it.

Do you have a lo-res candidate image in mind so I can test it?

@pmk01
Copy link
Contributor

pmk01 commented Feb 25, 2021

Yes, sorry, I couldn't come up with any immediately. Here are a couple of awkward examples from upcoming elections:
https://candidates.democracyclub.org.uk/person/72906/neil-wilson
https://candidates.democracyclub.org.uk/person/73218/gordon-shanks
https://candidates.democracyclub.org.uk/person/73540/michelle-frampton

@VirginiaDooley
Copy link
Contributor Author

VirginiaDooley commented Feb 25, 2021

Yes, sorry, I couldn't come up with any immediately. Here are a couple of awkward examples from upcoming elections:
https://candidates.democracyclub.org.uk/person/72906/neil-wilson
https://candidates.democracyclub.org.uk/person/73218/gordon-shanks
https://candidates.democracyclub.org.uk/person/73540/michelle-frampton

What do you think? Next question I have is why the logic is rendering with 0 elections. 🤔

Screen Shot 2021-02-25 at 8 49 34 AM

Screen Shot 2021-02-25 at 8 50 56 AM

Screen Shot 2021-02-25 at 8 52 49 AM

@pmk01
Copy link
Contributor

pmk01 commented Feb 25, 2021

Good stuff! No significant difference from now, then (in terms of picture quality).

@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch 2 times, most recently from 539427d to 6ec8bd9 Compare February 25, 2021 14:10
Copy link
Contributor Author

@VirginiaDooley VirginiaDooley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmk01 are you happy with this language?
Screen Shot 2021-02-25 at 9 20 53 AM

@pmk01
Copy link
Contributor

pmk01 commented Feb 25, 2021

Yes - how does it work with Mayors & PCCs?

@pmk01
Copy link
Contributor

pmk01 commented Feb 25, 2021

Here's a good candidate to try it on:
https://candidates.democracyclub.org.uk/person/6023/george-jabbour

@VirginiaDooley
Copy link
Contributor Author

Yes - how does it work with Mayors & PCCs?

Screen Shot 2021-02-25 at 9 53 21 AM

Happy to send the entire page; not sure if you just wanted to see Previous elections for https://candidates.democracyclub.org.uk/person/6023/george-jabbour

@symroe
Copy link
Member

symroe commented Feb 25, 2021

Sorry to jump in again, but for the "vote count not available" message on the table: we might have details about if they were elected or not, even if we don't have votes cast. For example, we'll have all general election results in terms of "elected: y/n".

Another thing to punt to an issue, but we should show that if we have it.

I think elected is a NullBoolean, so the values are one of None, True, False. e.g, if it's not None then we have asserted that they either were or weren't elected.

@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch from bcb3285 to 0876827 Compare February 25, 2021 14:57
@pmk01
Copy link
Contributor

pmk01 commented Feb 25, 2021

Further on results, do we want to add (not elected)? What do you guys think?

That table also reveals a number of problems with the names of our historic elections, especially Mayor of Watford, but I don't think any of that relates to this change. Something to return to after May, I think.

@VirginiaDooley
Copy link
Contributor Author

VirginiaDooley commented Feb 25, 2021

Sorry to jump in again, but for the "vote count not available" message on the table: we might have details about if they were elected or not, even if we don't have votes cast. For example, we'll have all general election results in terms of "elected: y/n".

Another thing to punt to an issue, but we should show that if we have it.

I think elected is a NullBoolean, so the values are one of None, True, False. e.g, if it's not None then we have asserted that they either were or weren't elected.

I think this is what you're referring to @symroe ? I've included an elected conditional regardless if votes_cast is available #660 (review)

@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch from 0876827 to 077ddb7 Compare February 25, 2021 15:10
@Heydon
Copy link
Collaborator

Heydon commented Mar 2, 2021

@VirginiaDooley The photo cropping issue is due to object-fit: cover which is used to fit the image into the available space by cropping rather than stretching. For some reason, the croppable area is two narrow in the pictured configuration, which I’ll need to tweak.

@Heydon
Copy link
Collaborator

Heydon commented Mar 2, 2021

@VirginiaDooley I'd have to see the markup, but we should be able to avoid this weird styling if the <details> element truncates the blockquote’s content, rather than splits it into two blockquotes? Is that what’s happening here?

blockquote split in two, breaking the border style

@VirginiaDooley
Copy link
Contributor Author

VirginiaDooley commented Mar 2, 2021

@VirginiaDooley I'd have to see the markup, but we should be able to avoid this weird styling if the <details> element truncates the blockquote’s content, rather than splits it into two blockquotes? Is that what’s happening here?

blockquote split in two, breaking the border style

@Heydon https://github.com/DemocracyClub/WhoCanIVoteFor/pull/660/files#diff-ae321f98dbcc359e064a2026d2dbbbefa7fc149669e954b138a7aee7ab749005

@Heydon
Copy link
Collaborator

Heydon commented Mar 3, 2021

@VirginiaDooley Okay, it seems you have a <blockquote> inside a <blockquote> there. I’ve added an example to the release/0.1.0 branch on how to do this successfully. https://github.com/DemocracyClub/design-system/blob/release/0.1.0/src-site/components/details.md

Note the use of class="ds-stack-smaller" for spacing.

<blockquote class="ds-stack-smaller">
  <p>To stand again as the UKIP candidate for Redcar is fantastic and reflects the fact I was born in Middlesbrough.</p>
  <details>
    <summary>Full statement</summary>
    <p>I work, run my business, and live in the constituency. What also makes me unique among the other candidates is my military service, having served in both the Regular Army and what is now the Reserve for forty two years.</p>
  </details>
</blockquote>

details opening and closing inside blockquote

@VirginiaDooley
Copy link
Contributor Author

Further on results, do we want to add (not elected)? What do you guys think?

That table also reveals a number of problems with the names of our historic elections, especially Mayor of Watford, but I don't think any of that relates to this change. Something to return to after May, I think.

Just following up, have you captured this somewhere already? If not I can make an issue.

<td>{{ person_post.post.label }}: {{ person_post.election }}</td>
<td>{{ person_post.party.party_name }}</td>
{% if person_post.elected %}
<td>{% if person_post.votes_cast %}{{ person_post.votes_cast|intcomma }} votes (elected){% else %}Vote count not available{% endif %}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think in the else here, we would want to say "Elected" rather than "Vote count not available"? Because we know they were elected (from the check on line 24) we just don't know how many votes they got

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now that I think about it, maybe we want to say both where the vote count is not available.

@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch from 81ed4d1 to c9dc066 Compare March 5, 2021 11:58
@VirginiaDooley VirginiaDooley force-pushed the feature/new-person-page branch from 8f16fe5 to 8f1672a Compare March 5, 2021 12:27
@VirginiaDooley VirginiaDooley merged commit 2c19637 into DemocracyClub:master Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants