Files
OSIT-AE-API-FastAPI/app/methods/event_registration_cfg_methods.py
2021-08-13 17:09:32 -04:00

46 lines
1.7 KiB
Python

from __future__ import annotations
import datetime
from typing import Dict, List, Optional, Set, Union
from pydantic import BaseModel, EmailStr, Field, PrivateAttr, ValidationError, validator
from app.db_sql import redis_lookup_id_random, sql_insert, sql_select, sql_update
from app.lib_general import log, logging
from app.models.event_registration_cfg_models import Event_Registration_Cfg_Base
# ### BEGIN ### API Event Registration Cfg Methods ### load_event_registration_cfg_obj() ###
def load_event_registration_cfg_obj(
event_id: int|str,
inc_event_registration_cfg: bool = False,
limit: int = 1000,
by_alias: bool = True,
exclude_unset: bool = True,
model_as_dict: bool = False,
) -> Event_Registration_Cfg_Base|bool:
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if event_id := redis_lookup_id_random(record_id_random=event_id, table_name='event'): pass
else: return False
if event_registration_cfg_rec := sql_select(table_name='event_registration_cfg', record_id=event_id): pass
else: return False
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_registration_cfg_rec)
try:
event_registration_cfg_obj = Event_Registration_Cfg_Base(**event_registration_cfg_rec)
log.debug(event_registration_cfg_obj)
except ValidationError as e:
log.error(e.json())
return False
if model_as_dict:
return event_registration_cfg_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
else:
return event_registration_cfg_obj
# ### END ### API Event Registration Cfg Methods ### load_event_registration_cfg_obj() ###