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

Commit

Permalink
Cap to three identities + misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed May 10, 2016
1 parent c235ea3 commit c483a6b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
5 changes: 5 additions & 0 deletions scss/pages/identities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
, lighten($green, 55%) 0%
, lighten($green, 30%) 100%
);
color: $green;
}

&.unverified {
color: $red;
}

&.add {
Expand Down
20 changes: 14 additions & 6 deletions www/~/%username/identities/%country.spt
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -42,7 +50,7 @@ if request.method == 'POST':
[---] text/html
{% extends "templates/profile.html" %}
{% block content %}
<img class="flag {{ country }}"
<img class="flag {{ country.code2 }}"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII=">
<div class="long-form">
<form autocomplete="off" action="" method="POST">
Expand Down Expand Up @@ -71,7 +79,7 @@ if request.method == 'POST':

<label class="half">
<span>{{ _("Date of Birth") }}</span>
<input id="dob" name="dob" required>
<input id="dob" name="dob" required value="{{ info['dob'] }}">
</label>

<label>
Expand Down
13 changes: 9 additions & 4 deletions www/~/%username/identities/index.spt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ request.allow('GET')
participant = get_participant(state, restrict=True)
title = _("Identities")
countries = sorted({v:k for k,v in locale.countries.items()}.items())
identities = participant.list_identity_metadata()
nidentities = len(identities)
[---] text/html
{% extends "templates/profile.html" %}
{% block content %}
<div id="identities">
{% for identity in participant.list_identity_metadata() %}
<div class="card {% if identity.is_verified %}verified{% else %}unverified{% endif %}">
{% for identity in identities %}
<a class="card {% if identity.is_verified %}verified{% else %}unverified{% endif %}"
href="{{ identity.country.code2 }}">
<h2>{{ locale.countries[identity.country.code2] }}</h2>
<img class="flag {{ identity.country.code2 }}"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII=">
Expand All @@ -20,18 +23,20 @@ countries = sorted({v:k for k,v in locale.countries.items()}.items())
{{ _("Unverified") }}
{% endif %}
</div>
</div>
</a>
{% endfor %}

{% if nidentities < 3 %}
<button class="card add open-country-chooser">
{{ _("Add Identity") }}
</button>
{% endif %}

<div class="clear"></div>

<div id="country-chooser">
<header>
<h2>Which Country?</h2>
<h2>{{ _("Which Country?") }}</h2>
<button class="close-country-chooser">&times;</button>
</header>
<section>
Expand Down

0 comments on commit c483a6b

Please sign in to comment.