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

Commit

Permalink
Refactor team mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Feb 20, 2017
1 parent 504882e commit aab9fac
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gratipay/models/participant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +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.team.takes import ZERO
from gratipay.security.crypto import constant_time_compare
from gratipay.utils import (
i18n,
Expand Down
10 changes: 7 additions & 3 deletions gratipay/models/team/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.,-_ ]+)$')
Expand All @@ -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.
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from gratipay.models import add_event


class ClosingMixin(object):
class Closing(object):
"""This mixin implements team closing.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down
7 changes: 0 additions & 7 deletions gratipay/models/team/mixins/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down
4 changes: 2 additions & 2 deletions tests/py/test_team_membership.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/py/test_team_takes.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/py/test_tip_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion www/%team/distributing/%to.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit aab9fac

Please sign in to comment.