Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Start working on limiting verifications in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Aug 22, 2017
1 parent 13009bc commit 006b59b
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 56 deletions.
11 changes: 11 additions & 0 deletions gratipay/models/participant/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ class Email(object):
"""

@property
def has_pending_email_address_verifications(self):
"""A boolean indicating whether there are email address verifications
outstanding for this participant. Makes a db call.
"""
for email in self.get_emails():
if not email.verified:
return True
return False


def start_email_verification(self, email, *packages):
"""Add an email address for a participant.
Expand Down
33 changes: 0 additions & 33 deletions scss/components/emails.scss

This file was deleted.

3 changes: 3 additions & 0 deletions scss/pages/emails.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#emails #content {

}
38 changes: 36 additions & 2 deletions tests/ttw/test_email_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

class Tests(BrowserHarness, QueuedEmailHarness):

def test_can_verify_email(self):
def setUp(self):
BrowserHarness.setUp(self)
QueuedEmailHarness.setUp(self)
self.make_participant('alice', claimed_time='now')
self.sign_in('alice')

def start_verification(self, email_address):
self.visit('/~alice/emails/')
self.css('#content input').fill('[email protected]')
self.css('#content button').click()
Expand All @@ -20,6 +24,36 @@ def test_can_verify_email(self):
, verification_email['body_text']
, re.DOTALL | re.MULTILINE
).groups()[0]
return verification_link

def attempt_verification(self, email_address):
verification_link = self.start_verification(email_address)
self.visit(verification_link)
assert self.css('#content h1').text == 'Success!'
return self.css('#content h1').text


def test_can_verify_email_address(self):
assert self.attempt_verification('[email protected]') == 'Success!'

def test_can_resend_when_pending(self):
self.start_verification('[email protected]')
assert self.attempt_verification('[email protected]') == 'Success!'

def test_can_reverify_when_already_verified(self):
raise NotImplementedError


def test_cannot_start_a_second_verification_while_one_open(self):
raise NotImplementedError


def test_can_start_a_second_verification_when_first_completed(self):
raise NotImplementedError


def test_verification_constraint_survives_remove_and_readd(self):
raise NotImplementedError


def test_verification_constraint_survives_close_and_reopen(self):
raise NotImplementedError
2 changes: 1 addition & 1 deletion www/assets/gratipay.css.spt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
@import "scss/components/cta";
@import "scss/components/danger-zone";
@import "scss/components/dropdown";
@import "scss/components/emails";
@import "scss/components/github-ribbon";
@import "scss/components/js-edit";
@import "scss/components/linear_gradient";
Expand Down Expand Up @@ -65,6 +64,7 @@
@import "scss/layouts/layout";
@import "scss/layouts/responsiveness";

@import "scss/pages/emails";
@import "scss/pages/homepage";
@import "scss/pages/history";
@import "scss/pages/identities";
Expand Down
50 changes: 30 additions & 20 deletions www/~/%username/emails/index.spt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ banner = '~' + participant.username
title = _("Emails")

emails = participant.get_emails()
page_id = 'emails'

[-----------------------------------------------------------------------------] text/html
{% extends "templates/profile.html" %}
Expand All @@ -17,26 +18,35 @@ emails = participant.get_emails()
{% endblock %}

{% block content %}
<div id="emails" class="emails">
<ul>
{% for email in emails %}
{% set is_primary = email.address == participant.email_address %}
<li class="{{ 'primary' if is_primary }} {{ 'verified' if email.verified }}"
data-email="{{ email.address }}">
{{ email.address }}
<span class="label-primary">{{ _("Primary") }}</span>
<span class="label-unverified">{{ _("Unverified") }}</span>
<button class="remove">{{ _("Remove") }}</button>
<button class="resend">{{ _("Resend") }}</button>
<button class="set-primary">{{ _("Set as primary") }}</button>
</li>
{% endfor %}
</ul>
<form class="add-email">
<input class="add-email" name="email" type="email" placeholder="[email protected]" />
<button type="submit">{{ _("Add email address") }}</button>
</form>
</div>
<table class="emails listing">
{% for i, email in enumerate(emails) %}
{% set is_primary = email.address == participant.email_address %}
<tr>
<td class="item" data-email="{{ email.address }}">
<span class="icon">&#xe007;</span>
<div class="listing-details">
<span class="listing-name">{{ email.address }}</span>
<span class="i">{{ i }}</span> &middot;
{% if email.verified %}
{% if is_primary %}
<span class="label-primary">{{ _("Primary") }}</span>
{% else %}
<button class="set-primary">{{ _("Set as primary") }}</button>
{% endif %} &middot;
<button class="remove">{{ _("Remove") }}</button>
{% else %}
<span class="label-unverified">{{ _("Unverified") }}</span> &middot;
<button class="resend">{{ _("Resend") }}</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table>
<form class="add-email">
<input class="add-email" name="email" type="email" placeholder="[email protected]" />
<button type="submit">{{ _("Add email address") }}</button>
</form>

<h2 id="notifications">{{ _("Notifications") }}</h2>
<div class="email-notifications">
Expand Down

0 comments on commit 006b59b

Please sign in to comment.