takes

class gratipay.models.team.takes.Takes[source]

Participant s who are members of a Team may take money from the team during Payday. Only the team owner may add a new member, by setting their take to a penny, but team owners may only set their take to a penny—no more. Team owners may also remove members, by setting their take to zero, as may the members themselves, who may also set their take to whatever they wish.

distributing = 0

The total amount of money the team distributes to participants (including the owner) during payday. Read-only; equal to receiving.

ndistributing_to = 0

The number of participants (including the owner) that the team distributes money to during payday. Read-only; modified by set_take_for().

set_take_for(participant, take, recorder, cursor=None)[source]

Set the amount a participant wants to take from this team during payday.

Parameters:
  • participant (Participant) – the participant to set the take for
  • take (Decimal) – the amount the participant wants to take
  • recorder (Participant) – the participant making the change
Returns:

the new take as a py:class:~decimal.Decimal

Raises:

NotAllowed

It is a bug to pass in a participant or recorder that is suspicious, unclaimed, or without a verified email and identity. Furthermore, NotAllowed is raised in the following circumstances:

  • recorder is neither participant nor the team owner
  • recorder is the team owner and take is neither zero nor $0.01
  • recorder is participant, but participant isn’t already on the team
get_take_for(participant, cursor=None)[source]
Parameters:
  • participant (Participant) – the participant to get the take for
  • cursor (GratipayDB) – a database cursor; if None, a new cursor will be used
Returns:

a Decimal: the participant‘s take from this team, or 0.

get_take_last_week_for(participant, cursor=None)[source]
Parameters:
  • participant (Participant) – the participant to get the take for
  • cursor (GratipayDB) – a database cursor; if None, a new cursor will be used
Returns:

a Decimal: the participant‘s take from this team at the beginning of the last completed payday, or 0.

update_taking(old_takes, new_takes, cursor=None, member=None)[source]

Update taking amounts based on the difference between old_takes and new_takes.

update_distributing(new_takes, cursor=None)[source]

Update the computed values on the team.

get_current_takes(cursor=None)[source]

Return a list of member takes for a team.

compute_actual_takes(cursor=None)[source]

Get the takes, compute the actual amounts, and return an OrderedDict.

exception gratipay.models.team.takes.NotAllowed[source]

Raised by set_take_for() if recorder is not allowed to set the take for participant.