diff --git a/gratipay/models/participant/__init__.py b/gratipay/models/participant/__init__.py index ff8d4732a0..2bd9beddec 100644 --- a/gratipay/models/participant/__init__.py +++ b/gratipay/models/participant/__init__.py @@ -37,8 +37,7 @@ from gratipay.models.account_elsewhere import AccountElsewhere from gratipay.models.exchange_route import ExchangeRoute from gratipay.models.team import Team -from gratipay.models.team.mixins.takes import ZERO -from gratipay.models.participant import mixins +from gratipay.models.team.takes import ZERO from gratipay.security.crypto import constant_time_compare from gratipay.utils import ( i18n, @@ -51,6 +50,7 @@ ) from gratipay.utils.username import safely_reserve_a_username +from .identity import Identity ASCII_ALLOWED_IN_USERNAME = set("0123456789" "abcdefghijklmnopqrstuvwxyz" @@ -63,7 +63,7 @@ USERNAME_MAX_SIZE = 32 -class Participant(Model, mixins.Identity): +class Participant(Model, Identity): """Represent a Gratipay participant. """ diff --git a/gratipay/models/participant/mixins/identity.py b/gratipay/models/participant/identity.py similarity index 99% rename from gratipay/models/participant/mixins/identity.py rename to gratipay/models/participant/identity.py index 50349a2046..f0257e4248 100644 --- a/gratipay/models/participant/mixins/identity.py +++ b/gratipay/models/participant/identity.py @@ -20,7 +20,7 @@ def _validate_info(schema_name, info): return None -class IdentityMixin(object): +class Identity(object): """This mixin provides management of national identities for :py:class:`~gratipay.models.participant.Participant` objects. diff --git a/gratipay/models/participant/mixins/__init__.py b/gratipay/models/participant/mixins/__init__.py deleted file mode 100644 index b05ab6ff13..0000000000 --- a/gratipay/models/participant/mixins/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .identity import IdentityMixin as Identity - -__all__ = ['Identity'] diff --git a/gratipay/models/team/__init__.py b/gratipay/models/team/__init__.py index ae14e74131..7df691aec3 100644 --- a/gratipay/models/team/__init__.py +++ b/gratipay/models/team/__init__.py @@ -10,9 +10,14 @@ from gratipay.billing.exchanges import MINIMUM_CHARGE from gratipay.exceptions import InvalidTeamName from gratipay.models import add_event -from gratipay.models.team import mixins from postgres.orm import Model +from .available import Available +from .closing import Closing +from .membership import Membership +from .takes import Takes +from .tip_migration import TipMigration + # Should have at least one letter. TEAM_NAME_PATTERN = re.compile(r'^(?=.*[A-Za-z])([A-Za-z0-9.,-_ ]+)$') @@ -33,8 +38,7 @@ def slugize(name): return slug -class Team(Model, mixins.Available, mixins.Closing, mixins.Membership, mixins.Takes, - mixins.TipMigration): +class Team(Model, Available, Closing, Membership, Takes, TipMigration): """Represent a Gratipay team. """ diff --git a/gratipay/models/team/mixins/available.py b/gratipay/models/team/available.py similarity index 91% rename from gratipay/models/team/mixins/available.py rename to gratipay/models/team/available.py index 5557d800cb..fd2fa95f24 100644 --- a/gratipay/models/team/mixins/available.py +++ b/gratipay/models/team/available.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals -class AvailableMixin(object): +class Available(object): """Teams can make money available for their members to take. """ diff --git a/gratipay/models/team/mixins/closing.py b/gratipay/models/team/closing.py similarity index 95% rename from gratipay/models/team/mixins/closing.py rename to gratipay/models/team/closing.py index 7ae3e517e7..838ea02e8c 100644 --- a/gratipay/models/team/mixins/closing.py +++ b/gratipay/models/team/closing.py @@ -4,7 +4,7 @@ from gratipay.models import add_event -class ClosingMixin(object): +class Closing(object): """This mixin implements team closing. """ diff --git a/gratipay/models/team/mixins/membership.py b/gratipay/models/team/membership.py similarity index 98% rename from gratipay/models/team/mixins/membership.py rename to gratipay/models/team/membership.py index 30b22631a7..2ca30aea52 100644 --- a/gratipay/models/team/mixins/membership.py +++ b/gratipay/models/team/membership.py @@ -3,7 +3,7 @@ from .takes import ZERO, PENNY -class MembershipMixin(object): +class Membership(object): """Teams may have zero or more members, who are participants that take money from the team. """ diff --git a/gratipay/models/team/mixins/__init__.py b/gratipay/models/team/mixins/__init__.py deleted file mode 100644 index e7635c01d2..0000000000 --- a/gratipay/models/team/mixins/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from .available import AvailableMixin as Available -from .closing import ClosingMixin as Closing -from .membership import MembershipMixin as Membership -from .takes import TakesMixin as Takes -from .tip_migration import TipMigrationMixin as TipMigration - -__all__ = ['Available', 'Closing', 'Membership', 'Takes', 'TipMigration'] diff --git a/gratipay/models/team/mixins/takes.py b/gratipay/models/team/takes.py similarity index 99% rename from gratipay/models/team/mixins/takes.py rename to gratipay/models/team/takes.py index 16a7bbcc43..00ac4d5804 100644 --- a/gratipay/models/team/mixins/takes.py +++ b/gratipay/models/team/takes.py @@ -7,7 +7,7 @@ PENNY = D('0.01') -class TakesMixin(object): +class Takes(object): """:py:class:`~gratipay.models.participant.Participant` s who are members of a :py:class:`~gratipay.models.team.Team` may take money from the team during :py:class:`~gratipay.billing.payday.Payday`. Only the team owner may diff --git a/gratipay/models/team/mixins/tip_migration.py b/gratipay/models/team/tip_migration.py similarity index 99% rename from gratipay/models/team/mixins/tip_migration.py rename to gratipay/models/team/tip_migration.py index bef47a3c0e..e45f6a4ea0 100644 --- a/gratipay/models/team/mixins/tip_migration.py +++ b/gratipay/models/team/tip_migration.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals -class TipMigrationMixin(object): +class TipMigration(object): """This mixin provides tip migration for teams. """ diff --git a/gratipay/wireup.py b/gratipay/wireup.py index 4604b17aba..184396c4e4 100644 --- a/gratipay/wireup.py +++ b/gratipay/wireup.py @@ -33,8 +33,7 @@ from gratipay.models.community import Community from gratipay.models.country import Country from gratipay.models.exchange_route import ExchangeRoute -from gratipay.models.participant import Participant -from gratipay.models.participant.mixins import Identity +from gratipay.models.participant import Participant, Identity from gratipay.models.team import Team from gratipay.models import GratipayDB from gratipay.security.crypto import EncryptingPacker diff --git a/tests/py/test_participant_identities.py b/tests/py/test_participant_identities.py index 1c807166ec..7faed93168 100644 --- a/tests/py/test_participant_identities.py +++ b/tests/py/test_participant_identities.py @@ -2,10 +2,10 @@ from cryptography.fernet import InvalidToken from gratipay.testing import Harness, P -from gratipay.models.participant.mixins import identity, Identity -from gratipay.models.participant.mixins.identity import _validate_info, rekey -from gratipay.models.participant.mixins.identity import ParticipantIdentityInfoInvalid -from gratipay.models.participant.mixins.identity import ParticipantIdentitySchemaUnknown +from gratipay.models.participant import identity +from gratipay.models.participant.identity import _validate_info, rekey +from gratipay.models.participant.identity import ParticipantIdentityInfoInvalid +from gratipay.models.participant.identity import ParticipantIdentitySchemaUnknown from gratipay.security.crypto import EncryptingPacker, Fernet from postgres.orm import ReadOnly from psycopg2 import IntegrityError @@ -148,7 +148,7 @@ def test_sii_validates_identity(self): ) def test_sii_happily_overwrites_schema_name(self): - packed = Identity.encrypting_packer.pack({'name': 'Crusher'}) + packed = identity.Identity.encrypting_packer.pack({'name': 'Crusher'}) self.db.run( "INSERT INTO participant_identities " "(participant_id, country_id, schema_name, info) " "VALUES (%s, %s, %s, %s)" diff --git a/tests/py/test_security.py b/tests/py/test_security.py index 21fd654e13..8119acdcd8 100644 --- a/tests/py/test_security.py +++ b/tests/py/test_security.py @@ -8,7 +8,7 @@ from base64 import urlsafe_b64decode from cryptography.fernet import Fernet, InvalidToken from gratipay import security -from gratipay.models.participant.mixins import Identity +from gratipay.models.participant import Identity from gratipay.security.crypto import EncryptingPacker from gratipay.testing import Harness from pytest import raises diff --git a/tests/py/test_team_membership.py b/tests/py/test_team_membership.py index cd48c8abbd..e22c126fd3 100644 --- a/tests/py/test_team_membership.py +++ b/tests/py/test_team_membership.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals from test_team_takes import TeamTakesHarness, PENNY -from gratipay.models.team import mixins +from gratipay.models.team.membership import Membership class Tests(TeamTakesHarness): @@ -15,7 +15,7 @@ def assert_memberships(self, *expected): def test_team_object_subclasses_takes_mixin(self): - assert isinstance(self.enterprise, mixins.Membership) + assert isinstance(self.enterprise, Membership) # gm - get_memberships diff --git a/tests/py/test_team_takes.py b/tests/py/test_team_takes.py index 6025ff85b9..715e41d7b1 100644 --- a/tests/py/test_team_takes.py +++ b/tests/py/test_team_takes.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals from pytest import raises -from gratipay.models.team.mixins.takes import NotAllowed, PENNY, ZERO +from gratipay.models.team.takes import NotAllowed, PENNY, ZERO from gratipay.testing import Harness, D,P,T from gratipay.testing.billing import PaydayMixin diff --git a/tests/py/test_tip_migration.py b/tests/py/test_tip_migration.py index 3dcd1e11b4..e9a683faec 100644 --- a/tests/py/test_tip_migration.py +++ b/tests/py/test_tip_migration.py @@ -2,7 +2,7 @@ import pytest from gratipay.testing import Harness -from gratipay.models.team.mixins.tip_migration import AlreadyMigrated, migrate_all_tips +from gratipay.models.team.tip_migration import AlreadyMigrated, migrate_all_tips class Tests(Harness): diff --git a/tests/ttw/test_team_distributing.py b/tests/ttw/test_team_distributing.py index 9227f7501a..c630dbea6a 100644 --- a/tests/ttw/test_team_distributing.py +++ b/tests/ttw/test_team_distributing.py @@ -20,9 +20,9 @@ def test_owner_can_add_a_member(self): self.sign_in('picard') self.visit('/TheEnterprise/distributing/') self.css('.lookup-container .query').first.fill('alice') - time.sleep(0.2) + time.sleep(0.3) self.css('.lookup-container button').first.click() - time.sleep(0.2) + time.sleep(0.3) assert [a.text for a in self.css('table.team a')] == ['alice'] diff --git a/www/%team/distributing/%to.json.spt b/www/%team/distributing/%to.json.spt index a28a929e26..8e7809a466 100644 --- a/www/%team/distributing/%to.json.spt +++ b/www/%team/distributing/%to.json.spt @@ -6,7 +6,7 @@ from aspen import Response from babel.numbers import NumberFormatError from gratipay.utils import get_team from gratipay.models.participant import Participant -from gratipay.models.team.mixins.takes import ZERO, PENNY +from gratipay.models.team.takes import ZERO, PENNY [--------------------] request.allow('POST')