Work on abstract submissions and related grants
This commit is contained in:
@@ -188,6 +188,7 @@ class Event_Abstract_Base_New(Core_Std_Obj_Base):
|
||||
|
||||
passcode: Optional[str]
|
||||
|
||||
grant_id: Optional[int]
|
||||
grant_code: Optional[str]
|
||||
grant_type_code: Optional[str]
|
||||
grant_json: Optional[Union[Json, None]]
|
||||
|
||||
212
app/models/grant_models.py
Normal file
212
app/models/grant_models.py
Normal file
@@ -0,0 +1,212 @@
|
||||
import datetime, pytz
|
||||
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationError, validator
|
||||
|
||||
from app.db_sql import redis_lookup_id_random
|
||||
from app.lib_general import log, logging
|
||||
|
||||
from app.models.common_field_schema import base_fields, default_num_bytes
|
||||
|
||||
from app.models.core_object_models import Core_Std_Obj_Base
|
||||
|
||||
|
||||
# ### BEGIN ### API Grant Models ### Grant_Base() ###
|
||||
# Update 2023-06-23
|
||||
class Grant_Base(BaseModel):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id_random: Optional[str] = Field(
|
||||
# **base_fields['grant_id_random'],
|
||||
alias = 'grant_id_random',
|
||||
)
|
||||
id: Optional[int] = Field(
|
||||
alias = 'grant_id'
|
||||
)
|
||||
|
||||
account_id_random: Optional[str]
|
||||
account_id: Optional[int]
|
||||
|
||||
event_id_random: Optional[str]
|
||||
event_id: Optional[int]
|
||||
|
||||
event_abstract_id_random: Optional[str]
|
||||
event_abstract_id: Optional[int]
|
||||
|
||||
# event_person_id_random: Optional[str] # This is the primary person/submitter
|
||||
# event_person_id: Optional[int]
|
||||
|
||||
for_type: Optional[str]
|
||||
for_id: Optional[int]
|
||||
|
||||
external_id: Optional[str]
|
||||
code: Optional[str]
|
||||
|
||||
name: Optional[str]
|
||||
description: Optional[str]
|
||||
|
||||
organization: Optional[str]
|
||||
state_province_name: Optional[str]
|
||||
|
||||
pi_given_name: Optional[str]
|
||||
pi_middle_name: Optional[str]
|
||||
pi_family_name: Optional[str]
|
||||
pi_email: Optional[str]
|
||||
pi_affiliations: Optional[str]
|
||||
|
||||
# passcode: Optional[str] # = '7777777'
|
||||
|
||||
# json: Optional[str] # "json" is reserved; need to change field name? json_str?
|
||||
json_str: Optional[Union[Json, None]] = Field(
|
||||
alias = 'json',
|
||||
)
|
||||
text: Optional[str]
|
||||
|
||||
enable: Optional[bool]
|
||||
hide: Optional[bool]
|
||||
priority: Optional[bool]
|
||||
sort: Optional[int]
|
||||
group: Optional[str]
|
||||
|
||||
notes: Optional[str]
|
||||
|
||||
created_on: Optional[datetime.datetime] = None
|
||||
updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
# Including other related objects
|
||||
# event_abstract: Optional[Event_Abstract_Base]
|
||||
event_abstract: Optional[dict]
|
||||
|
||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||
|
||||
@validator('id', always=True)
|
||||
def grant_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='grant')
|
||||
return None
|
||||
|
||||
@validator('account_id', always=True)
|
||||
def account_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('account_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='account')
|
||||
return None
|
||||
|
||||
@validator('event_id', always=True)
|
||||
def event_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('event_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='event')
|
||||
return None
|
||||
|
||||
@validator('event_abstract_id', always=True)
|
||||
def event_abstract_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('event_abstract_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='event_abstract')
|
||||
return None
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
allow_population_by_field_name = True
|
||||
fields = base_fields
|
||||
# ### END ### API Grant Models ### Grant_Base() ###
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API Grant Models ### Grant_Base() ###
|
||||
# Update 2023-06-23
|
||||
class Grant_Base_New(Core_Std_Obj_Base):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id_random: Optional[str] = Field(
|
||||
alias = 'grant_id_random',
|
||||
)
|
||||
|
||||
account_id_random: Optional[str]
|
||||
account_id: Optional[int]
|
||||
|
||||
event_id_random: Optional[str]
|
||||
event_id: Optional[int]
|
||||
|
||||
event_abstract_id: Optional[int]
|
||||
|
||||
for_type: Optional[str]
|
||||
for_id: Optional[int]
|
||||
|
||||
external_id: Optional[str]
|
||||
code: Optional[str]
|
||||
|
||||
# type_code: Optional[str]
|
||||
|
||||
description: Optional[str]
|
||||
text: Optional[str] # Actual grant text
|
||||
|
||||
organization: Optional[str]
|
||||
state_province_name: Optional[str]
|
||||
|
||||
pi_given_name: Optional[str]
|
||||
pi_middle_name: Optional[str]
|
||||
pi_family_name: Optional[str]
|
||||
pi_email: Optional[str]
|
||||
pi_affiliations: Optional[str]
|
||||
|
||||
# passcode: Optional[str]
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
allow_population_by_field_name = True
|
||||
fields = base_fields
|
||||
# ### END ### API Grant Models ### Grant_Base() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Grant Models ### Grant_In() ###
|
||||
# Update 2023-06-23
|
||||
class Grant_In(Grant_Base_New):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id: Optional[int] = Field(
|
||||
alias = 'grant_id'
|
||||
)
|
||||
|
||||
account_id: Optional[int]
|
||||
event_id: Optional[int]
|
||||
event_abstract_id: Optional[int]
|
||||
|
||||
@validator('id', always=True)
|
||||
def grant_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='grant')
|
||||
return None
|
||||
|
||||
@validator('event_id', always=True)
|
||||
def event_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('event_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='event')
|
||||
return None
|
||||
|
||||
@validator('event_abstract_id', always=True)
|
||||
def event_abstract_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('event_abstract_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='event_abstract')
|
||||
return None
|
||||
# ### END ### API Grant Models ### Grant_In() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Grant Models ### Grant_Ext() ###
|
||||
# Update 2023-06-23
|
||||
class Grant_Ext(Grant_Base_New):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# Including other related objects
|
||||
# event_abstract: Optional[Event_Abstract_Base]
|
||||
event_abstract: Optional[dict]
|
||||
# ### END ### API Grant Models ### Grant_Ext() ###
|
||||
Reference in New Issue
Block a user