added worksheet workflow

This commit is contained in:
Aurthur Musendame 2024-06-30 18:41:08 +02:00
parent 07d1f07260
commit 0fe6d6fed0
3 changed files with 68 additions and 15 deletions

View file

@ -5,20 +5,9 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="9f590b69-f929-45a1-8512-12ed6efbf028" name="Changes" comment="Added Invetory starter"> <list default="true" id="9f590b69-f929-45a1-8512-12ed6efbf028" name="Changes" comment="Added Invetory starter">
<change afterPath="$PROJECT_DIR$/felicity/apps/analysis/workflow/__init__.py" afterDir="false" /> <change afterPath="$PROJECT_DIR$/felicity/apps/worksheet/workflow/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/felicity/apps/analysis/workflow/analysis_result.py" afterDir="false" /> <change afterPath="$PROJECT_DIR$/felicity/apps/worksheet/workflow/worksheet.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/felicity/apps/analysis/workflow/qcset.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/felicity/apps/analysis/workflow/sample.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/felicity/api/gql/analysis/mutations/quality_control.py" beforeDir="false" afterPath="$PROJECT_DIR$/felicity/api/gql/analysis/mutations/quality_control.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/felicity/api/gql/impress/query.py" beforeDir="false" afterPath="$PROJECT_DIR$/felicity/api/gql/impress/query.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/felicity/apps/analysis/models/qc.py" beforeDir="false" afterPath="$PROJECT_DIR$/felicity/apps/analysis/models/qc.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/webapp/components/nav/NavigationAside.vue" beforeDir="false" afterPath="$PROJECT_DIR$/webapp/components/nav/NavigationAside.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/webapp/graphql/operations/analyses.mutations.ts" beforeDir="false" afterPath="$PROJECT_DIR$/webapp/graphql/operations/analyses.mutations.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/webapp/main.ts" beforeDir="false" afterPath="$PROJECT_DIR$/webapp/main.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/webapp/stores/sample.ts" beforeDir="false" afterPath="$PROJECT_DIR$/webapp/stores/sample.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/webapp/views/qcontrol/QualityControlListing.vue" beforeDir="false" afterPath="$PROJECT_DIR$/webapp/views/qcontrol/QualityControlListing.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/webapp/views/qcontrol/_id/QualityControl.vue" beforeDir="false" afterPath="$PROJECT_DIR$/webapp/views/qcontrol/_id/QualityControl.vue" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -66,17 +55,17 @@
"dart.analysis.tool.window.visible": "false", "dart.analysis.tool.window.visible": "false",
"git-widget-placeholder": "main", "git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true", "ignore.virus.scanning.warn.message": "true",
"last_opened_file_path": "/home/aurthurm/Documents/Development/felicity/felicity-lims/felicity/apps/analysis/workflow", "last_opened_file_path": "/home/aurthurm/Documents/Development/felicity/felicity-lims/felicity/apps/worksheet",
"settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings" "settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings"
} }
}]]></component> }]]></component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/felicity/apps/worksheet" />
<recent name="$PROJECT_DIR$/felicity/apps/analysis/workflow" /> <recent name="$PROJECT_DIR$/felicity/apps/analysis/workflow" />
<recent name="$PROJECT_DIR$/felicity/api/gql/analysis/mutations" /> <recent name="$PROJECT_DIR$/felicity/api/gql/analysis/mutations" />
<recent name="$PROJECT_DIR$/felicity/apps/guards" /> <recent name="$PROJECT_DIR$/felicity/apps/guards" />
<recent name="$PROJECT_DIR$/felicity/api/rest/api_v1/endpoints" /> <recent name="$PROJECT_DIR$/felicity/api/rest/api_v1/endpoints" />
<recent name="$PROJECT_DIR$/felicity" />
</key> </key>
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/felicity/version" /> <recent name="$PROJECT_DIR$/felicity/version" />

View file

@ -0,0 +1,64 @@
from felicity.apps.analysis import conf as analysis_conf
from felicity.apps.worksheet import conf
from felicity.apps.worksheet.models import WorkSheet
class WorksheetWorkFlowException(Exception):
...
class WorksheetWorkFlow:
"""WorksheetWorkFlow
Defines a set of guards that allow or prevent actions taken on Worksheet
"""
def __init__(self):
...
@classmethod
async def submit(cls, uid, submitter):
worksheet = await WorkSheet.get(uid=uid)
await cls._guard_submit(worksheet)
await worksheet.submit(submitter)
@staticmethod
async def _guard_submit(worksheet: WorkSheet) -> bool:
if worksheet.state not in [
conf.worksheet_states.PENDING,
conf.worksheet_states.SUBMITTING
]:
raise WorksheetWorkFlowException(f"Cannot submit a {worksheet.state} WorkSheet")
result_states = [analysis_conf.states.result.PENDING]
results, qc_results = await worksheet.get_analysis_results()
if len(list(filter(lambda ar: ar.status in result_states, results + qc_results))) > 0:
raise WorksheetWorkFlowException(f"Cannot submit a Worksheet with pending results")
return True
@classmethod
async def approve(cls, uid, approved_by):
worksheet = await WorkSheet.get(uid=uid)
await cls._guard_approve(worksheet)
await worksheet.verify(approved_by)
@staticmethod
async def _guard_approve(worksheet: WorkSheet) -> bool:
if worksheet.state not in [
conf.worksheet_states.AWAITING,
conf.worksheet_states.APPROVING
]:
raise WorksheetWorkFlowException(f"Cannot approve a {worksheet.state} WorkSheet")
result_states = [
analysis_conf.states.result.APPROVED,
analysis_conf.states.result.RETRACTED,
analysis_conf.states.result.CANCELLED
]
results, qc_results = await worksheet.get_analysis_results()
if not all([ar.status in result_states for ar in results + qc_results]):
raise WorksheetWorkFlowException(f"Cannot approve this Worksheet")
return True