From 97ef1c2743dbd94850264f103e7e8dc2d52af769 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 11 May 2016 19:24:20 -0400 Subject: [PATCH 01/13] update i18n files --- i18n/core/de.po | 3 +++ i18n/core/eo.po | 3 +++ i18n/core/fr.po | 3 +++ i18n/core/it.po | 3 +++ i18n/core/nl.po | 3 +++ i18n/core/pt.po | 3 +++ 6 files changed, 18 insertions(+) diff --git a/i18n/core/de.po b/i18n/core/de.po index e1b716e079..863758af3b 100644 --- a/i18n/core/de.po +++ b/i18n/core/de.po @@ -352,6 +352,9 @@ msgstr "Kreditkarte" msgid "PayPal" msgstr "" +msgid "verified in: {country}" +msgstr "" + msgid "Weekly" msgstr "" diff --git a/i18n/core/eo.po b/i18n/core/eo.po index bc1632abec..2bec046b39 100644 --- a/i18n/core/eo.po +++ b/i18n/core/eo.po @@ -343,6 +343,9 @@ msgstr "Kreditkarto" msgid "PayPal" msgstr "" +msgid "verified in: {country}" +msgstr "" + msgid "Weekly" msgstr "" diff --git a/i18n/core/fr.po b/i18n/core/fr.po index 6dabb7bfd5..a44e3ba0de 100644 --- a/i18n/core/fr.po +++ b/i18n/core/fr.po @@ -346,6 +346,9 @@ msgstr "Carte de crédit" msgid "PayPal" msgstr "" +msgid "verified in: {country}" +msgstr "" + msgid "Weekly" msgstr "" diff --git a/i18n/core/it.po b/i18n/core/it.po index a285e363b0..3200fa9e1d 100644 --- a/i18n/core/it.po +++ b/i18n/core/it.po @@ -343,6 +343,9 @@ msgstr "Carta di Credito" msgid "PayPal" msgstr "PayPal" +msgid "verified in: {country}" +msgstr "" + msgid "Weekly" msgstr "Settimanale" diff --git a/i18n/core/nl.po b/i18n/core/nl.po index 55164934cb..49c22c2480 100644 --- a/i18n/core/nl.po +++ b/i18n/core/nl.po @@ -345,6 +345,9 @@ msgstr "Kredietkaart" msgid "PayPal" msgstr "" +msgid "verified in: {country}" +msgstr "" + msgid "Weekly" msgstr "" diff --git a/i18n/core/pt.po b/i18n/core/pt.po index 0fdbcb9bf8..68e3e236ac 100644 --- a/i18n/core/pt.po +++ b/i18n/core/pt.po @@ -346,6 +346,9 @@ msgstr "Cartão de Crédito" msgid "PayPal" msgstr "" +msgid "verified in: {country}" +msgstr "" + msgid "Weekly" msgstr "" From 5ad22438db8a0727778029b495da60a1aa20bc03 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 11 May 2016 19:24:21 -0400 Subject: [PATCH 02/13] Bump version to 1963 --- www/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/version.txt b/www/version.txt index 67ce674bf0..812722cb80 100644 --- a/www/version.txt +++ b/www/version.txt @@ -1 +1 @@ -1962 +1963 From 87ae67ba469e04b10822ec0ffbc8f5403e9079dc Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Tue, 3 May 2016 20:47:55 -0400 Subject: [PATCH 03/13] start hacking on identity form --- www/~/%username/identities/index.spt | 20 ++++ www/~/%username/identity.spt | 151 --------------------------- 2 files changed, 20 insertions(+), 151 deletions(-) create mode 100644 www/~/%username/identities/index.spt delete mode 100644 www/~/%username/identity.spt diff --git a/www/~/%username/identities/index.spt b/www/~/%username/identities/index.spt new file mode 100644 index 0000000000..61e43ed25f --- /dev/null +++ b/www/~/%username/identities/index.spt @@ -0,0 +1,20 @@ +from gratipay.utils import get_participant +[---] +request.allow('GET', 'POST') +participant = get_participant(state, restrict=False) +title = _("Identities") +[---] text/html +{% extends "templates/profile.html" %} +{% block content %} +{% for identity in participant.list_identity_metadata() %} +

{{ locale.countries[identity.country.code2] }}{% if identity.is_verified %} ✓{% endif %}

+ {{ _('verified in: {country}', country=locale.countries[identity.country.code2]) }} +{% endfor %} + +
+ + +{% endblock %} diff --git a/www/~/%username/identity.spt b/www/~/%username/identity.spt deleted file mode 100644 index ee7898b11c..0000000000 --- a/www/~/%username/identity.spt +++ /dev/null @@ -1,151 +0,0 @@ -import balanced - -from gratipay.billing.exchanges import repr_exception -from gratipay.utils import get_participant - -[---] -request.allow('GET', 'POST') -participant = get_participant(state, restrict=True) -title = _("Identity Verification") -error = '' - -if request.method == 'POST': - account = participant.get_balanced_account() - - body = request.body - account.name = body.get('name') - account.address['line1'] = body.get('address_1') - account.address['line2'] = body.get('address_2') - account.address['postal_code'] = body.get('postal_code') - account.address['city'] = body.get('city') - account.address['state'] = body.get('region') - account.address['country_code'] = body.get('country') - account.phone = body.get('phone_number') - account.ssn_last4 = body.get('ssn_last4') or None - - dob = body.get('dob', '') - if dob: - try: - account.dob_year, account.dob_month, account.meta['dob_day'] = \ - map(int, dob.split('-')) - except ValueError: - error = _("Invalid date of birth.") - - if not error: - # This will possibly fail with 400 if formatted badly, or 300 if we - # cannot identify the merchant. - try: - account.save() - except balanced.exc.HTTPError as err: - error = repr_exception(err) - else: - if account.merchant_status != 'underwritten': - error = _("Unable to verify your identity") - -elif participant.balanced_customer_href: - account = participant.get_balanced_account() - -else: - account = balanced.Customer(address={}, meta={}) - -[---] text/html -{% extends "templates/profile.html" %} - -{% block scripts %} - {{ super() }} - -{% endblock %} - -{% block content %} - -{% if account.merchant_status == 'underwritten' %} -

{{ _( "Your identity is verified, which means you may add a {0}bank account{1}." - , ''|safe - , ''|safe) }}

-{% endif %} - -
-
- - - - - -
- - - - - - - - - - - -
- - - - - - - -
- - - -
-
- - - -
-
- -{% endblock %} From b3aec10bfb8e9823034524f701be2be8c91da6aa Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 9 May 2016 12:26:27 -0400 Subject: [PATCH 04/13] Start styling identities page --- scss/pages/identities.scss | 36 ++++++++++++++++++++++++++++ www/assets/gratipay.css.spt | 1 + www/~/%username/identities/index.spt | 19 ++++++++++++--- 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 scss/pages/identities.scss diff --git a/scss/pages/identities.scss b/scss/pages/identities.scss new file mode 100644 index 0000000000..690865d3aa --- /dev/null +++ b/scss/pages/identities.scss @@ -0,0 +1,36 @@ +#identities { + padding-top: 20px; + + .card { + height: 96px; + width: 46%; + float: left; + margin: 0 8% 8% 0; + padding: 20px; + position: relative; + @include border-radius(5px); + @include box-shadow(0, 0, 10px, $black); + + &:nth-child(even) { + margin-right: 0; + } + + img { + position: absolute; + bottom: 20px; + left: 20px; + } + + h2 { + white-space: nowrap; + margin: 0; + padding: 0; + } + + .status { + position: absolute; + bottom: 20px; + right: 20px; + } + } +} diff --git a/www/assets/gratipay.css.spt b/www/assets/gratipay.css.spt index 7897a39f78..fcdc7a27bd 100644 --- a/www/assets/gratipay.css.spt +++ b/www/assets/gratipay.css.spt @@ -59,6 +59,7 @@ @import "scss/pages/homepage"; @import "scss/pages/history"; +@import "scss/pages/identities"; @import "scss/pages/team"; @import "scss/pages/profile-edit"; @import "scss/pages/giving"; diff --git a/www/~/%username/identities/index.spt b/www/~/%username/identities/index.spt index 61e43ed25f..4af6dced40 100644 --- a/www/~/%username/identities/index.spt +++ b/www/~/%username/identities/index.spt @@ -6,15 +6,28 @@ title = _("Identities") [---] text/html {% extends "templates/profile.html" %} {% block content %} +
{% for identity in participant.list_identity_metadata() %} -

{{ locale.countries[identity.country.code2] }}{% if identity.is_verified %} ✓{% endif %}

+
+

{{ locale.countries[identity.country.code2] }}

{{ _('verified in: {country}', country=locale.countries[identity.country.code2]) }} +
+ {% if identity.is_verified %} + ✓ + {% else %} + {% endif %} +
+
{% endfor %} -
+ - +
+ +
{% endblock %} From 8c971f7c7aaa7b01d38c96f07bc742165c5724ee Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 9 May 2016 16:12:31 -0400 Subject: [PATCH 05/13] Move the add button into the visual background --- scss/pages/identities.scss | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scss/pages/identities.scss b/scss/pages/identities.scss index 690865d3aa..f73ee50b60 100644 --- a/scss/pages/identities.scss +++ b/scss/pages/identities.scss @@ -15,6 +15,19 @@ margin-right: 0; } + &.add { + background: #f6f6f6; + color: #aaa; + border-style: dashed; + @include box-shadow(0,0,0); + border: 2px dashed #ccc; + + &:hover { + color: $black; + background-image: radial-gradient(ellipse farthest-corner at 50% 50%, #ffffff 0%, #f6f6f6 70px); + } + } + img { position: absolute; bottom: 20px; From b1166687229070d234e1c4de339645e7c42b6624 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 9 May 2016 16:39:54 -0400 Subject: [PATCH 06/13] Style verified and unverified cards --- scss/pages/identities.scss | 21 +++++++++++++++++---- scss/variables.scss | 1 + www/~/%username/identities/index.spt | 9 ++++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/scss/pages/identities.scss b/scss/pages/identities.scss index f73ee50b60..2510831f5f 100644 --- a/scss/pages/identities.scss +++ b/scss/pages/identities.scss @@ -15,16 +15,26 @@ margin-right: 0; } + &.verified { + background-image: radial-gradient( circle at 36px 60px + , lighten($green, 55%) 0% + , lighten($green, 30%) 100% + ); + } + &.add { - background: #f6f6f6; - color: #aaa; + background: $lightest-gray; + color: $medium-gray; border-style: dashed; @include box-shadow(0,0,0); - border: 2px dashed #ccc; + border: 2px dashed $darker-gray; &:hover { color: $black; - background-image: radial-gradient(ellipse farthest-corner at 50% 50%, #ffffff 0%, #f6f6f6 70px); + background-image: radial-gradient( ellipse farthest-corner at 50% 50% + , $white 0% + , $lightest-gray 50% + ); } } @@ -38,12 +48,15 @@ white-space: nowrap; margin: 0; padding: 0; + overflow: hidden; + text-overflow: ellipsis; } .status { position: absolute; bottom: 20px; right: 20px; + font: normal 9px $Mono; } } } diff --git a/scss/variables.scss b/scss/variables.scss index 7475db78e8..17e846b23a 100644 --- a/scss/variables.scss +++ b/scss/variables.scss @@ -16,6 +16,7 @@ $medium-gray: #999; $gray: #555; $light-gray: #DDD; $lighter-gray: #EEE; +$lightest-gray: #F6F6F6; $red: #C00; $light-red: #F99; diff --git a/www/~/%username/identities/index.spt b/www/~/%username/identities/index.spt index 4af6dced40..e0bac3bba4 100644 --- a/www/~/%username/identities/index.spt +++ b/www/~/%username/identities/index.spt @@ -8,23 +8,22 @@ title = _("Identities") {% block content %}
{% for identity in participant.list_identity_metadata() %} -
+

{{ locale.countries[identity.country.code2] }}

{{ _('verified in: {country}', country=locale.countries[identity.country.code2]) }}
{% if identity.is_verified %} - ✓ + {{ _("Verified") }} {% else %} + {{ _("Unverified") }} {% endif %}
{% endfor %}
From 7bd20b46511dbad3522e7d2643dd95620023fd4e Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 9 May 2016 17:26:15 -0400 Subject: [PATCH 07/13] Start a national identity form -- the form itself! --- www/~/%username/identities/%country.spt | 41 +++++++++++++++++++++++++ www/~/%username/identities/index.spt | 4 +-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 www/~/%username/identities/%country.spt diff --git a/www/~/%username/identities/%country.spt b/www/~/%username/identities/%country.spt new file mode 100644 index 0000000000..9b185e7cbc --- /dev/null +++ b/www/~/%username/identities/%country.spt @@ -0,0 +1,41 @@ +from aspen import Response +from gratipay.utils import get_participant +[---] +participant = get_participant(state, restrict=True) +identities = participant.list_identity_metadata() +country = request.path['country'] +if country not in locale.countries: + raise Response(404) +title = locale.countries[country] +identity = None +for identity in identities: + if identity.country.code2 == country: + identity = participant.retrieve_identity_info(identity.country.id) + break +[---] text/html +{% extends "templates/profile.html" %} +{% block content %} + +
+ Legal Name:
+ Address:
+ Date of Birth:
+
+ ID Number:
+ ID Type:
+   National ID
+   Passport
+   Driver's License
+
+ + +
+ +{% if identity != None %} +
+

Remove this Identity

+ +
+{% endif %} +{% endblock %} diff --git a/www/~/%username/identities/index.spt b/www/~/%username/identities/index.spt index e0bac3bba4..ff9fe87775 100644 --- a/www/~/%username/identities/index.spt +++ b/www/~/%username/identities/index.spt @@ -1,7 +1,7 @@ from gratipay.utils import get_participant [---] -request.allow('GET', 'POST') -participant = get_participant(state, restrict=False) +request.allow('GET') +participant = get_participant(state, restrict=True) title = _("Identities") [---] text/html {% extends "templates/profile.html" %} From b4b96f9bbc0e9826aea85b155f48da44b1768a9a Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 9 May 2016 20:45:07 -0400 Subject: [PATCH 08/13] Add a country chooser to the Identities page --- js/gratipay.js | 1 + js/gratipay/countryChooser.js | 18 ++++ .../cc-ba.scss => components/long-form.scss} | 17 ++- scss/pages/identities.scss | 72 +++++++++++++ www/assets/gratipay.css.spt | 2 +- www/~/%username/identities/%country.spt | 102 ++++++++++++++---- www/~/%username/identities/index.spt | 53 +++++---- www/~/%username/routes/credit-card.spt | 2 +- 8 files changed, 225 insertions(+), 42 deletions(-) create mode 100644 js/gratipay/countryChooser.js rename scss/{pages/cc-ba.scss => components/long-form.scss} (89%) diff --git a/js/gratipay.js b/js/gratipay.js index aa0a5e92b1..68eb6483df 100644 --- a/js/gratipay.js +++ b/js/gratipay.js @@ -18,6 +18,7 @@ Gratipay.init = function() { Gratipay.signOut(); Gratipay.payments.initSupportGratipay(); Gratipay.tabs.init(); + Gratipay.countryChooser.init(); }; Gratipay.warnOffUsersFromDeveloperConsole = function() { diff --git a/js/gratipay/countryChooser.js b/js/gratipay/countryChooser.js new file mode 100644 index 0000000000..9d88c4bcaf --- /dev/null +++ b/js/gratipay/countryChooser.js @@ -0,0 +1,18 @@ +Gratipay.countryChooser = {} + +Gratipay.countryChooser.init = function() { + $('.open-country-chooser').click(Gratipay.countryChooser.open); + $('.close-country-chooser').click(Gratipay.countryChooser.close); + $('#grayout').click(Gratipay.countryChooser.close); +}; + +Gratipay.countryChooser.open = function() { + $('.open-country-chooser').blur(); + $('#grayout').show() + $('#country-chooser').show(); +}; + +Gratipay.countryChooser.close = function() { + $('#country-chooser').hide() + $('#grayout').hide() +}; diff --git a/scss/pages/cc-ba.scss b/scss/components/long-form.scss similarity index 89% rename from scss/pages/cc-ba.scss rename to scss/components/long-form.scss index c2f82e3785..0f4ae26581 100644 --- a/scss/pages/cc-ba.scss +++ b/scss/components/long-form.scss @@ -1,4 +1,4 @@ -.cc-ba { +.long-form { width: 300px; form { @@ -113,4 +113,19 @@ input.invalid:focus + .invalid-msg { display: block; } + + .danger-zone { + margin-top: 64px; + border: 1px solid $red; + @include border-radius(5px); + padding: 20px; + h2 { + margin: 0 0 10px; + padding: 0; + color: $red; + } + button { + background: $red; + } + } } diff --git a/scss/pages/identities.scss b/scss/pages/identities.scss index 2510831f5f..414b3aed96 100644 --- a/scss/pages/identities.scss +++ b/scss/pages/identities.scss @@ -59,4 +59,76 @@ font: normal 9px $Mono; } } + + #country-chooser { + z-index: 1001; + display: none; + background: white; + @include border-radius(5px); + @include box-shadow(0, 0, 10px, $black); + position: fixed; + width: 240px; + height: 50vh; + top: 25%; + left: 50%; + margin-left: -120px; + + header { + position: absolute; + top: 0; + left: 0; + z-index: 1; + width: 240px; + height: 36px; + background: white; + border-bottom: 1px solid $black; + @include border-radius(5px 5px 0 0); + @include box-shadow(0, 0, 10px, $black); + + h2 { + margin: 0; + padding: 12px 20px 0; + } + button { + position: absolute; + top: 5px; + right: 20px; + } + } + + section { + overflow: auto; + height: 50vh; + z-index: 0; + margin-top: 36px; + background: $lightest-gray; + @include border-radius(0 0 5px 5px); + @include box-shadow(0, 0, 10px, $black); + + a { + padding: 5px 20px; + display: block; + img { + margin: 0 5px -10px 0; + } + span { + font: bold 18px/18px $Ideal; + } + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + } + } + + #grayout { + width: 100vw; + height: 100vh; + position: fixed; + top: 0; + left: 0; + background: transparentize($black, 0.3); + z-index: 1000; + display: none; + } } diff --git a/www/assets/gratipay.css.spt b/www/assets/gratipay.css.spt index fcdc7a27bd..ba695d7dda 100644 --- a/www/assets/gratipay.css.spt +++ b/www/assets/gratipay.css.spt @@ -35,6 +35,7 @@ @import "scss/components/js-edit"; @import "scss/components/linear_gradient"; @import "scss/components/loading-indicators"; +@import "scss/components/long-form"; @import "scss/components/memberships"; @import "scss/components/nav"; @import "scss/components/payments-by"; @@ -64,7 +65,6 @@ @import "scss/pages/profile-edit"; @import "scss/pages/giving"; @import "scss/pages/settings"; -@import "scss/pages/cc-ba"; @import "scss/pages/on-confirm"; @import "scss/pages/search"; @import "scss/pages/hall-of-fame"; diff --git a/www/~/%username/identities/%country.spt b/www/~/%username/identities/%country.spt index 9b185e7cbc..af04958997 100644 --- a/www/~/%username/identities/%country.spt +++ b/www/~/%username/identities/%country.spt @@ -8,34 +8,94 @@ if country not in locale.countries: raise Response(404) title = locale.countries[country] identity = None +info = {} for identity in identities: if identity.country.code2 == country: - identity = participant.retrieve_identity_info(identity.country.id) + info = participant.retrieve_identity_info(identity.country.id) break + +if request.method == 'POST': + info = {} + info['id_type'] = request.body['id_type'] + info['id_number'] = request.body['id_number'] + info['legal_name'] = request.body['legal_name'] + info['address_1'] = request.body['address_1'] + info['address_2'] = request.body['address_2'] + info['city'] = request.body['city'] + info['region'] = request.body['region'] + info['postcode'] = request.body['postcode'] + participant.store_identity_info(info) + request.redirect('..') + [---] text/html {% extends "templates/profile.html" %} {% block content %} -
- Legal Name:
- Address:
- Date of Birth:
-
- ID Number:
- ID Type:
-   National ID
-   Passport
-   Driver's License
-
- - -
- -{% if identity != None %} -
-

Remove this Identity

- +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + {% if identity != None %} +
+

{{ _("Danger Zone") }}

+ +
+ {% endif %} +
-{% endif %} {% endblock %} diff --git a/www/~/%username/identities/index.spt b/www/~/%username/identities/index.spt index ff9fe87775..2e9104eb89 100644 --- a/www/~/%username/identities/index.spt +++ b/www/~/%username/identities/index.spt @@ -3,30 +3,47 @@ from gratipay.utils import get_participant request.allow('GET') participant = get_participant(state, restrict=True) title = _("Identities") +countries = sorted({v:k for k,v in locale.countries.items()}.items()) [---] text/html {% extends "templates/profile.html" %} {% block content %}
-{% for identity in participant.list_identity_metadata() %} -
-

{{ locale.countries[identity.country.code2] }}

- -
- {% if identity.is_verified %} - {{ _("Verified") }} - {% else %} - {{ _("Unverified") }} - {% endif %} + {% for identity in participant.list_identity_metadata() %} +
+

{{ locale.countries[identity.country.code2] }}

+ +
+ {% if identity.is_verified %} + {{ _("Verified") }} + {% else %} + {{ _("Unverified") }} + {% endif %} +
-
-{% endfor %} + {% endfor %} - + -
+
-
+
+
+

Which Country?

+ +
+
+ {% for name, code in countries %} + + + {{ name }} + + {% endfor %} +
+
+
+
{% endblock %} diff --git a/www/~/%username/routes/credit-card.spt b/www/~/%username/routes/credit-card.spt index c06feb99ba..0627848de1 100644 --- a/www/~/%username/routes/credit-card.spt +++ b/www/~/%username/routes/credit-card.spt @@ -46,7 +46,7 @@ else:

{{ last_bill_result }}

{% endif %}
-
+

{{ _("Required") }}

From 621c7eb2aca649e345d764cbeccfc8cc2359cfcb Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 9 May 2016 21:01:49 -0400 Subject: [PATCH 09/13] Add autofocus and a cancel button --- www/~/%username/identities/%country.spt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/www/~/%username/identities/%country.spt b/www/~/%username/identities/%country.spt index af04958997..66af1100cf 100644 --- a/www/~/%username/identities/%country.spt +++ b/www/~/%username/identities/%country.spt @@ -48,7 +48,8 @@ if request.method == 'POST':