Pre-refactor
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
Used to construct models from input dictionaries.
|
||||
'''
|
||||
from getpass import getuser
|
||||
from tools import Settings, RSLNamer, check_regex_match
|
||||
from tools import Settings, RSLNamer, check_regex_match, check_authorization, massage_common_reagents
|
||||
from .. import models
|
||||
from .lookups import *
|
||||
import logging
|
||||
@@ -190,6 +190,7 @@ def construct_samples(ctx:Settings, instance:models.BasicSubmission, samples:Lis
|
||||
continue
|
||||
return instance
|
||||
|
||||
@check_authorization
|
||||
def construct_kit_from_yaml(ctx:Settings, kit_dict:dict) -> dict:
|
||||
"""
|
||||
Create and store a new kit in the database based on a .yml file
|
||||
@@ -197,16 +198,16 @@ def construct_kit_from_yaml(ctx:Settings, kit_dict:dict) -> dict:
|
||||
|
||||
Args:
|
||||
ctx (Settings): Context object passed down from frontend
|
||||
exp (dict): Experiment dictionary created from yaml file
|
||||
kit_dict (dict): Experiment dictionary created from yaml file
|
||||
|
||||
Returns:
|
||||
dict: a dictionary containing results of db addition
|
||||
"""
|
||||
from tools import check_is_power_user, massage_common_reagents
|
||||
# from tools import check_is_power_user, massage_common_reagents
|
||||
# Don't want just anyone adding kits
|
||||
if not check_is_power_user(ctx=ctx):
|
||||
logger.debug(f"{getuser()} does not have permission to add kits.")
|
||||
return {'code':1, 'message':"This user does not have permission to add kits.", "status":"warning"}
|
||||
# if not check_is_power_user(ctx=ctx):
|
||||
# logger.debug(f"{getuser()} does not have permission to add kits.")
|
||||
# return {'code':1, 'message':"This user does not have permission to add kits.", "status":"warning"}
|
||||
submission_type = lookup_submission_type(ctx=ctx, name=kit_dict['used_for'])
|
||||
logger.debug(f"Looked up submission type: {kit_dict['used_for']} and got {submission_type}")
|
||||
kit = models.KitType(name=kit_dict["kit_name"])
|
||||
|
||||
@@ -258,4 +258,3 @@ def get_polymorphic_subclass(base:object, polymorphic_identity:str|None=None):
|
||||
logger.error(f"Could not get polymorph {polymorphic_identity} of {base} due to {e}")
|
||||
return base
|
||||
|
||||
|
||||
@@ -294,6 +294,19 @@ class BasicSubmission(Base):
|
||||
Workbook: updated workbook
|
||||
"""
|
||||
return input_excel
|
||||
|
||||
@classmethod
|
||||
def enforce_naming_schema(cls, input_str:str) -> str:
|
||||
"""
|
||||
Used to ensure proper custom naming of submission.
|
||||
|
||||
Args:
|
||||
input_str (str): name parsed by default parser
|
||||
|
||||
Returns:
|
||||
str: custom parser output.
|
||||
"""
|
||||
return input_str
|
||||
|
||||
# Below are the custom submission types
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Contains pydantic models and accompanying validators
|
||||
'''
|
||||
import uuid
|
||||
from pydantic import BaseModel, field_validator, Extra, Field
|
||||
from pydantic import BaseModel, field_validator, Field
|
||||
from datetime import date, datetime
|
||||
from dateutil.parser import parse
|
||||
from dateutil.parser._parser import ParserError
|
||||
@@ -74,7 +74,7 @@ class PydReagent(BaseModel):
|
||||
|
||||
|
||||
|
||||
class PydSubmission(BaseModel, extra=Extra.allow):
|
||||
class PydSubmission(BaseModel, extra='allow'):
|
||||
ctx: Settings
|
||||
filepath: Path
|
||||
submission_type: dict|None
|
||||
|
||||
Reference in New Issue
Block a user