Skip to content

Index

hypha.apply.funds.workflows

Workflow System Documentation

This package implements a flexible workflow system for managing application states and transitions. The system is built on the following key concepts:

  • Workflow: Overall process definition containing stages and phases
  • Stage: Major sections of the workflow (e.g. Request, Proposal)
  • Phase: Individual states within a stage
  • Transition: Allowed movements between phases

Key Components: - models/: Core workflow model classes - definitions/: Workflow configuration definitions - registry.py: Central workflow registration and lookup - permissions.py: Permission checking system

DETERMINATION_OUTCOMES module-attribute

DETERMINATION_OUTCOMES = get_determination_transitions()

DRAFT_STATE module-attribute

DRAFT_STATE = 'draft'

INITIAL_STATE module-attribute

INITIAL_STATE = 'in_discussion'

STAGE_CHANGE_ACTIONS module-attribute

STAGE_CHANGE_ACTIONS = get_stage_change_actions()

PHASES module-attribute

PHASES = list(from_iterable(items() for workflow in values()))

STATUSES module-attribute

STATUSES = defaultdict(set)

WORKFLOWS module-attribute

WORKFLOWS = {admin_name: Request, admin_name: RequestSameTime, admin_name: RequestExternal, admin_name: RequestCommunity, admin_name: ConceptProposal}

accepted_statuses module-attribute

accepted_statuses = get_accepted_statuses()

active_statuses module-attribute

active_statuses = [status for (status, _) in PHASES if 'accepted' not in status and 'rejected' not in status and 'invited' not in status]

dismissed_statuses module-attribute

dismissed_statuses = get_dismissed_statuses()

ext_or_higher_statuses module-attribute

ext_or_higher_statuses = get_ext_or_higher_statuses()

ext_review_statuses module-attribute

ext_review_statuses = get_ext_review_statuses()

review_statuses module-attribute

review_statuses = get_review_statuses()

UserPermissions

Bases: Enum

STAFF class-attribute instance-attribute

STAFF = 1

ADMIN class-attribute instance-attribute

ADMIN = 2

LEAD class-attribute instance-attribute

LEAD = 3

APPLICANT class-attribute instance-attribute

APPLICANT = 4

Stage

Stage(name, has_external_review=False)
Source code in hypha/apply/funds/workflows/models/stage.py
4
5
6
def __init__(self, name: str, has_external_review: bool = False) -> None:
    self.name = name
    self.has_external_review = has_external_review

name instance-attribute

name = name

has_external_review instance-attribute

has_external_review = has_external_review

get_review_active_statuses

get_review_active_statuses(user=None)
Source code in hypha/apply/funds/workflows/registry.py
def get_review_active_statuses(user=None):
    reviews = set()

    for phase_name, phase in PHASES:
        if phase_name in active_statuses:
            if user is None:
                reviews.add(phase_name)
            elif phase.permissions.can_review(user):
                reviews.add(phase_name)
    return reviews

get_action_mapping

get_action_mapping(workflow)
Source code in hypha/apply/funds/workflows/utils.py
def get_action_mapping(workflow):
    from .registry import PHASES

    # Maps action names to the phase they originate from
    transitions = defaultdict(lambda: {"display": "", "transitions": []})
    if workflow:
        phases = workflow.items()
    else:
        phases = PHASES
    for _phase_name, phase in phases:
        for transition_name, transition in phase.transitions.items():
            transition_display = transition["display"]
            transition_key = slugify(transition_display)
            transitions[transition_key]["transitions"].append(transition_name)
            transitions[transition_key]["display"] = transition_display

    return transitions