Example state
This example state shows a possible technical review of a new project including a task for a further decision.
Technical review: Directory structure
Section titled “Technical review: Directory structure”Directoryperseus
Directorystates
Directorycustom
- __init__.py
- TechnicalReview.py Our example
- …
- __init__.py
- BaseState.py
- Task.py
Technical review state
Section titled “Technical review state”from perseus.datamanager import Projectfrom perseus.security import CoreRoleNamefrom perseus.frontend_form import TextBlock
from ..BaseState import BaseStatefrom ..Task import Task
class TechnicalReview(BaseState): @classmethod def initialize(cls): TechnicalReview.add_permission(CoreRoleName.OWNER) TechnicalReview.add_permission(CoreRoleName.TECHNICAL_REVIEWER) TechnicalReview.add_frontend_menu_item("Technical Review", "DeveloperBoard")
@classmethod def get_task_ids(cls) -> list[str]: return ["CHECKING"]
@classmethod def get_tasks( cls, include_form: bool = True, project_id: str | None = None, **kwargs ) -> list[Task]: tasks = [] for project in TechnicalReview.get_state_projects():
form = TechnicalReview.get_basic_form(project, "CHECKING") if project.source is not None: form.add_items( TextBlock( f"# Technical review for #{project.source.foreign_id} ({project.source.name}) - {project.title}" ) ) else: form.add_items(TextBlock(f"# Technical review for {project.title}")) form.add_items( TextBlock( f"<a href='/ProjectSearch/{str(project.db_id)}' target='_blank'>View all proposal details</a>" ) ) form.add_items( TextBlock("Please only proceed if the technical review finished successfully.") ) tasks.append( Task( id="CHECKING", title=( f"Technical Review for project <a href='/ProjectSearch/{str(project.db_id)}' target='_blank'> #{project.source.foreign_id} ({project.source.name})</a>" if project.source is not None else f"Technical Review for project {project.title}" ), project_id=str(project.db_id), assignee=TechnicalReview.task_assignee(project, "CHECKING"), form=form, project_type=project.project_type, ) ) return tasks
@classmethod def handle_action(cls, project: Project, task_id: str, content: dict): TechnicalReview.trigger_event( project, "APPROVED", "Approved technical review", TechnicalReview.task_assignee(project, task_id), )