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

bring back takes/membership UI #4026

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f366481
add schema and Python for countries
chadwhitacre Apr 30, 2016
1339acc
implement encrypted national identities
chadwhitacre Apr 30, 2016
a29256c
delete participant identity during account closing
chadwhitacre May 9, 2016
bcdab77
reject identities for participants with no email
chadwhitacre May 9, 2016
292ab36
add rekeying
chadwhitacre May 9, 2016
f29df33
add schema and Python for [un]verifying identities
chadwhitacre Apr 30, 2016
44472ca
implement clearing identities
chadwhitacre Apr 30, 2016
f0c8ce7
implement has_verified_identity
chadwhitacre Apr 30, 2016
2b9d5f4
clean up fake_data.py a little
chadwhitacre Apr 30, 2016
5e52739
add fake participant identities w/ dashboard
chadwhitacre May 1, 2016
97e4705
show verified identities on profile with flags
chadwhitacre May 1, 2016
c1d07b3
start hacking on identity form
chadwhitacre May 4, 2016
6795407
Start styling identities page
chadwhitacre May 9, 2016
d553599
Move the add button into the visual background
chadwhitacre May 9, 2016
23c26b4
Style verified and unverified cards
chadwhitacre May 9, 2016
a1c9e22
Start a national identity form -- the form itself!
chadwhitacre May 9, 2016
0d571e1
Add a country chooser to the Identities page
chadwhitacre May 10, 2016
a54400f
Add autofocus and a cancel button
chadwhitacre May 10, 2016
1e5bec0
Add a helper to Country; should go upstream prolly
chadwhitacre May 10, 2016
3ceb2e8
POSTing identities! :O
chadwhitacre May 10, 2016
31bdb10
Cap to three identities + misc cleanup
chadwhitacre May 10, 2016
0fb4d28
move team to a subdir as w/ participant
chadwhitacre May 4, 2016
c04b34a
Remove old takes and payroll table
chadwhitacre May 11, 2016
ecc79dc
implement takes
chadwhitacre May 11, 2016
ca05a1d
implement membership
chadwhitacre May 11, 2016
1a2ad56
start stubbing out takes in payday
chadwhitacre May 6, 2016
4ad245d
start stubbing out takes UI
chadwhitacre May 6, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bin/rekey.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/usr/bin/env python2
"""See gratipay.models.participant.mixins.identity.rekey for documentation.
"""
from __future__ import absolute_import, division, print_function, unicode_literals

from gratipay import wireup
from gratipay.models.participant.mixins import identity as participant_identities

env = wireup.env()
db = wireup.db(env)
wireup.crypto(env)
packer = wireup.crypto(env)

print("{} record(s) rekeyed.".format(0)) # stubbed until we have something to rekey
n = participant_identities.rekey(db, packer)
print("Rekeyed {} participant identity record(s).".format(n))
22 changes: 22 additions & 0 deletions gratipay/models/country.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from postgres.orm import Model


class Country(Model):
"""Represent country records from our database (read-only).

:var int id: the record's primary key in our ``countries`` table
:var unicode name: the name of the country
:var unicode code2: the country's `ISO 3166-1 alpha-2`_ code
:var unicode code3: the country's `ISO 3166-1 alpha-3`_ code

.. _ISO 3166-1 alpha-2 : https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
.. _ISO 3166-1 alpha-3 : https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3

"""
typname = 'countries'

@classmethod
def from_code2(cls, code2):
return cls.db.one("SELECT countries.*::countries FROM countries WHERE code2=%s", (code2,))
30 changes: 3 additions & 27 deletions gratipay/models/participant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from gratipay.models.account_elsewhere import AccountElsewhere
from gratipay.models.exchange_route import ExchangeRoute
from gratipay.models.team import Team
from gratipay.models.participant import mixins
from gratipay.security.crypto import constant_time_compare
from gratipay.utils import (
i18n,
Expand All @@ -60,7 +61,7 @@

USERNAME_MAX_SIZE = 32

class Participant(Model):
class Participant(Model, mixins.Identity):
"""Represent a Gratipay participant.
"""

Expand Down Expand Up @@ -333,14 +334,6 @@ def clear_payment_instructions(self, cursor):
self.set_payment_instruction(team, '0.00', update_self=False, cursor=cursor)


def clear_takes(self, cursor):
"""Leave all teams by zeroing all takes.
"""
for team, nmembers in self.get_old_teams():
t = Participant.from_username(team)
t.set_take_for(self, Decimal(0), self, cursor)


def clear_personal_information(self, cursor):
"""Clear personal information such as statements.
"""
Expand All @@ -355,6 +348,7 @@ def clear_personal_information(self, cursor):

DELETE FROM emails WHERE participant_id = %(participant_id)s;
DELETE FROM statements WHERE participant=%(participant_id)s;
DELETE FROM participant_identities WHERE participant_id=%(participant_id)s;

UPDATE participants
SET anonymous_giving=False
Expand Down Expand Up @@ -1093,22 +1087,6 @@ def get_teams(self, only_approved=False, cursor=None):
return teams


def get_old_teams(self):
"""Return a list of old-style teams this user was a member of.
"""
return self.db.all("""

SELECT team AS name
, ( SELECT count(*)
FROM current_takes
WHERE team=x.team
) AS nmembers
FROM current_takes x
WHERE member=%s;

""", (self.username,))


def insert_into_communities(self, is_member, name, slug):
participant_id = self.id
self.db.run("""
Expand Down Expand Up @@ -1517,8 +1495,6 @@ def take_over(self, account, have_confirmation=False):

if this_is_others_last_login_account:

other.clear_takes(cursor)

# Take over tips.
# ===============

Expand Down
3 changes: 3 additions & 0 deletions gratipay/models/participant/mixins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .identity import IdentityMixin as Identity

__all__ = ['Identity']
Loading