Cycle Manager

g2p_programs.models.managers.cycle_manager provides the class BaseCycleManager define the interface for this manager. DefaultCycleManager is the default implementation of this class that should be used in most of the cases.

class g2p_programs.models.managers.cycle_manager.BaseCycleManager(*args: Any, **kwargs: Any)[source]
add_beneficiaries(cycle, beneficiaries, state='draft')[source]

Add beneficiaries to the cycle

check_eligibility(cycle, beneficiaries=None)[source]

Validate the eligibility of each beneficiary for the cycle

mark_cancelled(cycle)[source]

Mark the cycle as cancelled

mark_distributed(cycle)[source]

Mark the cycle as distributed

mark_ended(cycle)[source]

Mark the cycle as ended

new_cycle(name, new_start_date, sequence)[source]

Create a new cycle for the program

on_start_date_change(cycle)[source]

Hook for when the start date change

on_state_change(cycle)[source]

Hook for when the state change Args:

cycle:

Returns:

prepare_entitlements(cycle)[source]

Prepare the entitlements for the cycle

validate_entitlements(cycle, cycle_memberships)[source]

Validate the entitlements for the cycle

class g2p_programs.models.managers.cycle_manager.DefaultCycleManager(*args: Any, **kwargs: Any)[source]
add_beneficiaries(cycle, beneficiaries, state='draft')[source]

Add beneficiaries to the cycle

check_eligibility(cycle, beneficiaries=None)[source]
Parameters
  • cycle (g2p_programs.models.cycle.G2PCycle) – The cycle that is being verified

  • beneficiaries (list or None) – the beneficiaries that need to be verified. By Default the one with the state draft or enrolled are verified.

Returns

The list of eligible beneficiaries

Return type

list

Validate the eligibility of each beneficiary for the cycle using the configured manager(s) g2p_programs.models.managers.eligibility_manager.BaseEligibilityManager. If there is multiple managers for eligibility, each of them are run using the filtered list of eligible beneficiaries from the previous one.

The state of beneficiaries is updated to either enrolled if they match the enrollment criteria or not_eligible in case they do not match them.

copy_beneficiaries_from_program(cycle, state='enrolled')[source]
cycle_duration = 'Cycle Duration'
mark_cancelled(cycle)[source]
mark_distributed(cycle)[source]
mark_ended(cycle)[source]
new_cycle(name, new_start_date, sequence)[source]
on_state_change(cycle)[source]
prepare_entitlements(cycle)[source]
validate_entitlements(cycle, cycle_memberships)[source]