From eddad56495b3b2c0ef6266a3da1aed83f82dbbdc Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 9 May 2016 21:30:00 -0400 Subject: [PATCH] Cap to three identities + misc cleanup --- scss/pages/identities.scss | 5 +++++ tests/py/test_pages.py | 1 + www/~/%username/identities/%country.spt | 20 ++++++++++++++------ www/~/%username/identities/index.spt | 13 +++++++++---- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/scss/pages/identities.scss b/scss/pages/identities.scss index 414b3aed96..99e0e9c238 100644 --- a/scss/pages/identities.scss +++ b/scss/pages/identities.scss @@ -20,6 +20,11 @@ , lighten($green, 55%) 0% , lighten($green, 30%) 100% ); + color: $green; + } + + &.unverified { + color: $red; } &.add { diff --git a/tests/py/test_pages.py b/tests/py/test_pages.py index f89f1b1b29..9048434bcc 100644 --- a/tests/py/test_pages.py +++ b/tests/py/test_pages.py @@ -31,6 +31,7 @@ def browse(self, setup=None, **kw): .replace('/%platform/', '/github/') \ .replace('/%user_name/', '/gratipay/') \ .replace('/%membername', '/alan') \ + .replace('/%country', '/TT') \ .replace('/%exchange_id.int', '/%s' % exchange_id) \ .replace('/%redirect_to', '/giving') \ .replace('/%endpoint', '/public') \ diff --git a/www/~/%username/identities/%country.spt b/www/~/%username/identities/%country.spt index d9660b4446..d3b6c50deb 100644 --- a/www/~/%username/identities/%country.spt +++ b/www/~/%username/identities/%country.spt @@ -14,21 +14,29 @@ title = locale.countries[country.code2] # load identity & info identity = None info = {} -for identity in participant.list_identity_metadata(): - if identity.country.code2 == country.code2: - info = participant.retrieve_identity_info(identity.country.id) +identities = participant.list_identity_metadata() +nidentities = len(identities) +for _identity in identities: + if _identity.country.code2 == country.code2: + identity = _identity + info = participant.retrieve_identity_info(_identity.country.id) break +if identity is None and nidentities >= 3: + website.redirect('./', base_url='') # Not allowed to add any more! # handle POST requests if request.method == 'POST': action = request.body['action'] if action == 'remove': - participant.remove_identity_info(country.id) + participant.clear_identity(country.id) elif action == 'store': + if identity is None and nidentities > 3: + raise Response(400, 'Only three identities allowed.') # How'd you get here? info = {} info['id_type'] = request.body['id_type'] info['id_number'] = request.body['id_number'] info['legal_name'] = request.body['legal_name'] + info['dob'] = request.body['dob'] info['address_1'] = request.body['address_1'] info['address_2'] = request.body['address_2'] info['city'] = request.body['city'] @@ -42,7 +50,7 @@ if request.method == 'POST': [---] text/html {% extends "templates/profile.html" %} {% block content %} -
@@ -71,7 +79,7 @@ if request.method == 'POST':