This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add fake participant identities w/ dashboard
- Loading branch information
1 parent
b598c27
commit 398cf90
Showing
3 changed files
with
132 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,9 @@ def test_fake_data(self): | |
assert len(payment_instructions) == num_tips | ||
else: | ||
assert len(payment_instructions) == (num_participants - num_teams) | ||
|
||
|
||
def test_fake_participant_identity(self): | ||
crusher = self.make_participant('crusher', email_address='[email protected]') | ||
country_id = fake_data.fake_participant_identity(crusher) | ||
assert [x.country.id for x in crusher.list_identity_metadata()] == [country_id] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from aspen import Response | ||
|
||
[---] | ||
if not user.ADMIN: | ||
raise Response(403) | ||
|
||
countries = website.db.all(""" | ||
|
||
SELECT name | ||
, array_agg(username) as usernames | ||
, array_agg(is_verified) as verifications | ||
FROM participant_identities pi | ||
JOIN participants p | ||
ON p.id = participant_id | ||
JOIN countries c | ||
ON c.id = country_id | ||
GROUP BY c.name | ||
|
||
""") | ||
|
||
multiple = website.db.all(""" | ||
|
||
WITH counts AS ( | ||
SELECT participant_id, count(*) count | ||
FROM participant_identities | ||
GROUP BY participant_id | ||
) | ||
SELECT p.*::participants | ||
FROM participants p | ||
JOIN counts c | ||
ON p.id = c.participant_id | ||
WHERE c.count > 1 | ||
|
||
""") | ||
|
||
zip = zip | ||
[---] text/html | ||
<h1>Multiple</h1> | ||
{% for participant in multiple %} | ||
<a href="/~{{ participant.username }}/">{{ participant.username }}</a> | ||
{% for identity in participant.list_identity_metadata() %} | ||
| {% if identity.is_verified %} | ||
<b>{{ identity.country.name }}</b> | ||
{% else %} | ||
{{ identity.country.name }} | ||
{% endif %} | ||
{% endfor %} | ||
<br> | ||
{% endfor %} | ||
|
||
<h1>By Country</h1> | ||
{% for country in countries %} | ||
<b>{{ country.name }}</b> | ||
{% for username, is_verified in zip(country.usernames, country.verifications) %} | ||
| {% if is_verified %} | ||
<b><a href="/~{{ username }}/">{{ username }}</a></b> | ||
{% else %} | ||
<a href="/~{{ username }}/">{{ username }}</a> | ||
{% endif %} | ||
{% endfor %} | ||
<br> | ||
{% endfor %} |