Bugs squashed.
This commit is contained in:
@@ -471,6 +471,21 @@ class Reagent(Base):
|
||||
pass
|
||||
return query_return(query=query, limit=limit)
|
||||
|
||||
def update_last_used(self, kit:KitType):
|
||||
report = Report()
|
||||
logger.debug(f"Attempting update of reagent type at intersection of ({self}), ({kit})")
|
||||
rt = ReagentType.query(kit_type=kit, reagent=self, limit=1)
|
||||
if rt != None:
|
||||
logger.debug(f"got reagenttype {rt}")
|
||||
assoc = KitTypeReagentTypeAssociation.query(kit_type=kit, reagent_type=rt)
|
||||
if assoc != None:
|
||||
if assoc.last_used != self.lot:
|
||||
logger.debug(f"Updating {assoc} last used to {self.lot}")
|
||||
assoc.last_used = self.lot
|
||||
result = assoc.save()
|
||||
return(report.add_result(result))
|
||||
return report.add_result(Result(msg=f"Updating last used {rt} was not performed.", status="Information"))
|
||||
|
||||
class Discount(Base):
|
||||
"""
|
||||
Relationship table for client labs for certain kits.
|
||||
|
||||
@@ -25,7 +25,6 @@ from dateutil.parser._parser import ParserError
|
||||
import yaml
|
||||
from sqlalchemy.exc import OperationalError as AlcOperationalError, IntegrityError as AlcIntegrityError, StatementError
|
||||
from sqlite3 import OperationalError as SQLOperationalError, IntegrityError as SQLIntegrityError
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
@@ -572,6 +571,17 @@ class BasicSubmission(Base):
|
||||
except AttributeError:
|
||||
logger.error(f"Could not set {self} attribute {key} to {value}")
|
||||
|
||||
def update_subsampassoc(self, sample:BasicSample, input_dict:dict):
|
||||
assoc = SubmissionSampleAssociation.query(submission=self, sample=sample, limit=1)
|
||||
for k,v in input_dict.items():
|
||||
try:
|
||||
setattr(assoc, k, v)
|
||||
except AttributeError:
|
||||
logger.error(f"Can't set {k} to {v}")
|
||||
# result = store_object(ctx=ctx, object=assoc)
|
||||
result = assoc.save()
|
||||
return result
|
||||
|
||||
# Below are the custom submission types
|
||||
|
||||
class BacterialCulture(BasicSubmission):
|
||||
@@ -925,6 +935,8 @@ class WastewaterArtic(BasicSubmission):
|
||||
input_dict['csv'] = df
|
||||
return input_dict
|
||||
|
||||
# Sample Classes
|
||||
|
||||
class BasicSample(Base):
|
||||
"""
|
||||
Base of basic sample which polymorphs into BCSample and WWSample
|
||||
@@ -1115,6 +1127,8 @@ class BasicSample(Base):
|
||||
instance.sample_type = sample_type
|
||||
return instance
|
||||
|
||||
#Below are the custom sample types
|
||||
|
||||
class WastewaterSample(BasicSample):
|
||||
"""
|
||||
Derivative wastewater sample
|
||||
@@ -1199,6 +1213,8 @@ class BacterialCultureSample(BasicSample):
|
||||
sample['name'] = f"{self.submitter_id} - ({self.organism})"
|
||||
return sample
|
||||
|
||||
# Submission to Sample Associations
|
||||
|
||||
class SubmissionSampleAssociation(Base):
|
||||
"""
|
||||
table containing submission/sample associations
|
||||
|
||||
Reference in New Issue
Block a user