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
DRAFT_STATE
module-attribute
INITIAL_STATE
module-attribute
INITIAL_STATE = 'in_discussion'
STAGE_CHANGE_ACTIONS
module-attribute
PHASES
module-attribute
PHASES = list(from_iterable(items() for workflow in values()))
STATUSES
module-attribute
STATUSES = defaultdict(set)
WORKFLOWS
module-attribute
accepted_statuses
module-attribute
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
ext_or_higher_statuses
module-attribute
ext_review_statuses
module-attribute
review_statuses
module-attribute
UserPermissions
Bases: Enum
STAFF
class-attribute
instance-attribute
ADMIN
class-attribute
instance-attribute
LEAD
class-attribute
instance-attribute
APPLICANT
class-attribute
instance-attribute
Stage
Stage(name, has_external_review=False)
Source code in hypha/apply/funds/workflows/models/stage.py
| def __init__(self, name: str, has_external_review: bool = False) -> None:
self.name = name
self.has_external_review = has_external_review
|
has_external_review
instance-attribute
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
|