During code cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import logging, re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from openpyxl import load_workbook
|
||||
from backend.db.models import BasicSubmission, SubmissionType
|
||||
@@ -79,6 +80,8 @@ class RSLNamer(object):
|
||||
except UnboundLocalError:
|
||||
check = True
|
||||
if check:
|
||||
if "pytest" in sys.modules:
|
||||
return "Bacterial Culture"
|
||||
# logger.debug("Final option, ask the user for submission type")
|
||||
from frontend.widgets import ObjectSelector
|
||||
dlg = ObjectSelector(title="Couldn't parse submission type.",
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Contains pydantic models and accompanying validators
|
||||
'''
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from operator import attrgetter
|
||||
import uuid, re, logging
|
||||
from pydantic import BaseModel, field_validator, Field, model_validator, PrivateAttr
|
||||
@@ -431,10 +433,14 @@ class PydSubmission(BaseModel, extra='allow'):
|
||||
value['value'] = None
|
||||
if value['value'] is None:
|
||||
value['missing'] = True
|
||||
if "pytest" in sys.modules:
|
||||
value['value'] = "Nosocomial"
|
||||
return value
|
||||
from frontend.widgets.pop_ups import ObjectSelector
|
||||
dlg = ObjectSelector(title="Missing Submitting Lab",
|
||||
message="We need a submitting lab. Please select from the list.",
|
||||
obj_type=Organization)
|
||||
|
||||
if dlg.exec():
|
||||
value['value'] = dlg.parse_form()
|
||||
else:
|
||||
@@ -651,9 +657,13 @@ class PydSubmission(BaseModel, extra='allow'):
|
||||
logger.debug(f"Setting {key} to {value}")
|
||||
match key:
|
||||
case "reagents":
|
||||
if code == 1:
|
||||
instance.submission_reagent_associations = []
|
||||
logger.debug(f"Looking through {self.reagents}")
|
||||
for reagent in self.reagents:
|
||||
reagent, assoc = reagent.toSQL(submission=instance)
|
||||
if assoc is not None and assoc not in instance.submission_reagent_associations:
|
||||
logger.debug(f"Association: {assoc}")
|
||||
if assoc is not None:# and assoc not in instance.submission_reagent_associations:
|
||||
instance.submission_reagent_associations.append(assoc)
|
||||
# instance.reagents.append(reagent)
|
||||
case "samples":
|
||||
@@ -666,13 +676,13 @@ class PydSubmission(BaseModel, extra='allow'):
|
||||
case "equipment":
|
||||
logger.debug(f"Equipment: {pformat(self.equipment)}")
|
||||
try:
|
||||
if equip == None:
|
||||
if equip is None:
|
||||
continue
|
||||
except UnboundLocalError:
|
||||
continue
|
||||
for equip in self.equipment:
|
||||
equip, association = equip.toSQL(submission=instance)
|
||||
if association != None:
|
||||
if association is not None:
|
||||
association.save()
|
||||
logger.debug(
|
||||
f"Equipment association SQL object to be added to submission: {association.__dict__}")
|
||||
@@ -719,7 +729,7 @@ class PydSubmission(BaseModel, extra='allow'):
|
||||
# We need to make sure there's a proper rsl plate number
|
||||
logger.debug(f"We've got a total cost of {instance.run_cost}")
|
||||
try:
|
||||
logger.debug(f"Constructed instance: {instance.to_string()}")
|
||||
logger.debug(f"Constructed instance: {instance}")
|
||||
except AttributeError as e:
|
||||
logger.debug(f"Something went wrong constructing instance {self.rsl_plate_num}: {e}")
|
||||
logger.debug(f"Constructed submissions message: {msg}")
|
||||
|
||||
Reference in New Issue
Block a user