Working on all the routes, methods, and models.
This commit is contained in:
@@ -5,7 +5,7 @@ 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 *
|
||||
from app.lib_general import log, logging
|
||||
|
||||
from app.models.common_field_schema import base_fields, default_num_bytes
|
||||
from app.models.account_cfg_models import Account_Cfg_Base
|
||||
@@ -28,8 +28,10 @@ class Account_Base(BaseModel):
|
||||
default_factory=lambda:secrets.token_urlsafe(default_num_bytes),
|
||||
)
|
||||
id: Optional[int] = Field(
|
||||
#alias='account_id'
|
||||
alias='account_id'
|
||||
)
|
||||
# account_id: Optional[int] = Field(
|
||||
# )
|
||||
|
||||
code: Optional[str]
|
||||
name: Optional[str]
|
||||
@@ -44,6 +46,8 @@ class Account_Base(BaseModel):
|
||||
created_on: Optional[datetime.datetime] = None
|
||||
updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
testing: Optional[str]
|
||||
|
||||
# Including other related objects
|
||||
account_cfg: Optional[Account_Cfg_Base] # Priority l1
|
||||
address_list: Optional[list] # Address_Base() # Priority l3
|
||||
@@ -65,15 +69,6 @@ class Account_Base(BaseModel):
|
||||
|
||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||
|
||||
#@validator('account_id_random', always=True)
|
||||
def account_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_id_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
@@ -84,6 +79,16 @@ class Account_Base(BaseModel):
|
||||
return redis_lookup_id_random(record_id_random=values['id_random'], table_name='account')
|
||||
return None
|
||||
|
||||
# @validator('account_id', always=True)
|
||||
# def account_id_duplicate(cls, v, values, **kwargs):
|
||||
# log.setLevel(logging.DEBUG)
|
||||
# log.debug(locals())
|
||||
|
||||
# if values['id']:
|
||||
# log.debug(values['id'])
|
||||
# return values['id']
|
||||
# return None
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
fields = base_fields
|
||||
|
||||
Reference in New Issue
Block a user