Moving stuff around to make it more easy to manage
This commit is contained in:
71
app/methods/account_cfg_methods.py
Normal file
71
app/methods/account_cfg_methods.py
Normal file
@@ -0,0 +1,71 @@
|
||||
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_select
|
||||
from app.lib_general import log, logging
|
||||
|
||||
from app.methods.event_methods import load_event_obj
|
||||
|
||||
from app.models.account_cfg_models import Account_Cfg_Base
|
||||
# from app.models.membership_cfg_models import Membership_Cfg_Base
|
||||
|
||||
|
||||
# ### BEGIN ### API Account Methods ### load_account_cfg_obj() ###
|
||||
def load_account_cfg_obj(account_id:int|str) -> Account_Cfg_Base|bool:
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else: return False
|
||||
|
||||
if account_cfg_rec := sql_select(table_name='v_account_cfg', field_name='account_id', field_value=account_id):
|
||||
log.debug(account_cfg_rec)
|
||||
|
||||
try:
|
||||
account_cfg_obj = Account_Cfg_Base(**account_cfg_rec)
|
||||
log.debug(account_cfg_obj)
|
||||
except ValidationError as e:
|
||||
log.error(e.json())
|
||||
|
||||
return account_cfg_obj
|
||||
else: return False
|
||||
# ### END ### API Account Methods ### load_account_cfg_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Account Methods ### load_account_cfg_obj() ###
|
||||
# def load_account_cfg_obj(account_id:int|str, inc_event_cfg:bool=False, inc_fundraising_cfg:bool=False, inc_membership_cfg:bool=False):
|
||||
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
# if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
# else: return False
|
||||
|
||||
# if account_cfg_rec := sql_select(table_name='v_account_cfg', field_name='account_id', field_value=account_id):
|
||||
# log.debug(account_cfg_rec)
|
||||
|
||||
# try:
|
||||
# account_cfg_obj = Account_Cfg_Base(**account_cfg_rec)
|
||||
# log.debug(account_cfg_obj)
|
||||
# except ValidationError as e:
|
||||
# log.error(e.json())
|
||||
|
||||
# return account_cfg_obj
|
||||
# else: return False
|
||||
|
||||
# if inc_membership_cfg:
|
||||
# if membership_cfg_rec := sql_select(table_name='v_membership_cfg', field_name='account_id', field_value=account_id):
|
||||
# #log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(membership_cfg_rec)
|
||||
|
||||
# #account_rec['membership_cfg'] = membership_cfg_rec
|
||||
# try:
|
||||
# membership_cfg_obj = Membership_Cfg_Base(**membership_cfg_rec)
|
||||
# log.debug(membership_cfg_obj)
|
||||
# except ValidationError as e:
|
||||
# log.error(e.json())
|
||||
|
||||
# return membership_cfg_obj
|
||||
# ### END ### API Account Methods ### load_account_cfg_obj() ###
|
||||
Reference in New Issue
Block a user