Clean up and debugging.

This commit is contained in:
Scott Idem
2023-01-30 17:59:13 -05:00
parent b510a44adf
commit a9f0e2bf3d
3 changed files with 13 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
import datetime, hashlib, logging, os, pytz, redis, secrets
import datetime, pytz
from typing import Dict, List, Optional, Set, Union
from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationError, validator
@@ -11,12 +11,13 @@ from app.models.fundraising_cfg_models import Fundraising_Cfg_Base
from app.models.membership_cfg_models import Membership_Cfg_Base
# ### BEGIN ### API Account Cfg Models ### Account_Cfg_Base() ###
class Account_Cfg_Base(BaseModel):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(
**base_fields['account_cfg_id_random'],
# **base_fields['account_cfg_id_random'],
alias = 'account_cfg_id_random',
)
id: Optional[int] = Field(
@@ -112,35 +113,22 @@ class Account_Cfg_Base(BaseModel):
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
#@validator('account_cfg_id_random', always=True)
def account_cfg_id_random_copy(cls, v, values, **kwargs):
log.setLevel(logging.WARNING)
log.debug(locals())
if values['id_random']:
return values['id_random']
return None
@validator('id', always=True)
def account_cfg_id_lookup(cls, v, values, **kwargs):
log.setLevel(logging.WARNING)
log.debug(locals())
if values['id_random']:
log.debug(values['id_random'])
return redis_lookup_id_random(record_id_random=values['id_random'], table_name='account_cfg')
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='account_cfg')
return None
@validator('account_id', always=True)
def account_id_lookup(cls, v, values, **kwargs):
log.setLevel(logging.DEBUG)
log.debug(locals())
if values['account_id_random']:
return redis_lookup_id_random(record_id_random=values['account_id_random'], table_name='account')
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
class Config:
underscore_attrs_are_private = True
allow_population_by_field_name = True
fields = base_fields
# ### END ### API Account Cfg Models ### Account_Cfg_Base() ###

View File

@@ -179,11 +179,9 @@ class Event_Base(BaseModel):
@validator('account_id', always=True)
def account_id_lookup(cls, v, values, **kwargs):
log.setLevel(logging.WARNING)
log.debug(locals())
if values['account_id_random']:
return redis_lookup_id_random(record_id_random=values['account_id_random'], table_name='account')
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('poc_event_person_id', always=True)

View File

@@ -7,13 +7,11 @@ 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.event_models import Event_Base
# from app.models.event_abstract_models import Event_Abstract_Base
from app.models.event_cfg_models import Event_Cfg_Base
from app.models.event_person_models import Event_Person_Base
# from app.models.event_presentation_models import Event_Presentation_Base
# from app.models.event_session_models import Event_Session_Base
# from app.models.person_models import Person_Base
# ### BEGIN ### API Event Presenter Models ### Event_Presenter_Base() ###