Unknown
This commit is contained in:
@@ -63,11 +63,10 @@ def load_event_file_obj(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
event_file_obj = Event_File_Base(**event_file_rec)
|
event_file_obj = Event_File_Base(**event_file_rec)
|
||||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
|
||||||
log.debug(event_file_obj)
|
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
log.error(e.json())
|
log.error(e.json())
|
||||||
return False
|
return False
|
||||||
|
log.debug(event_file_obj)
|
||||||
|
|
||||||
if inc_hosted_file and hosted_file_id:
|
if inc_hosted_file and hosted_file_id:
|
||||||
log.info('Need to include hosted file...')
|
log.info('Need to include hosted file...')
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
from __future__ import annotations
|
|
||||||
import datetime, hashlib, logging, os, pytz, redis, secrets
|
import datetime, hashlib, logging, os, pytz, redis, secrets
|
||||||
|
|
||||||
from typing import Dict, List, Optional, Set, Union
|
from typing import Dict, List, Optional, Set, Union
|
||||||
@@ -101,93 +100,71 @@ class Event_File_Base(BaseModel):
|
|||||||
|
|
||||||
#@validator('event_file_id_random', always=True)
|
#@validator('event_file_id_random', always=True)
|
||||||
def event_file_id_random_copy(cls, v, values, **kwargs):
|
def event_file_id_random_copy(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
if values['id_random']:
|
if values['id_random']:
|
||||||
return values['id_random']
|
return values['id_random']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('id', always=True)
|
@validator('id', always=True)
|
||||||
def event_file_id_lookup(cls, v, values, **kwargs):
|
def event_file_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event_file')
|
||||||
if values['id_random']:
|
|
||||||
log.debug(values['id_random'])
|
|
||||||
return redis_lookup_id_random(record_id_random=values['id_random'], table_name='event_file')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('hosted_file_id', always=True)
|
@validator('hosted_file_id', always=True)
|
||||||
def hosted_file_id_lookup(cls, v, values, **kwargs):
|
def hosted_file_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('hosted_file_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='hosted_file')
|
||||||
if values['hosted_file_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['hosted_file_id_random'], table_name='hosted_file')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('event_id', always=True)
|
@validator('event_id', always=True)
|
||||||
def event_id_lookup(cls, v, values, **kwargs):
|
def event_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('event_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event')
|
||||||
if values['event_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['event_id_random'], table_name='event')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('event_exhibit_id', always=True)
|
@validator('event_exhibit_id', always=True)
|
||||||
def event_exhibit_id_lookup(cls, v, values, **kwargs):
|
def event_exhibit_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('event_exhibit_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event_exhibit')
|
||||||
if values['event_exhibit_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['event_exhibit_id_random'], table_name='event_exhibit')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('event_location_id', always=True)
|
@validator('event_location_id', always=True)
|
||||||
def event_location_id_lookup(cls, v, values, **kwargs):
|
def event_location_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('event_location_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event_location')
|
||||||
if values['event_location_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['event_location_id_random'], table_name='event_location')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('event_presentation_id', always=True)
|
@validator('event_presentation_id', always=True)
|
||||||
def event_presentation_id_lookup(cls, v, values, **kwargs):
|
def event_presentation_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('event_presentation_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event_presentation')
|
||||||
if values['event_presentation_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['event_presentation_id_random'], table_name='event_presentation')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('event_presenter_id', always=True)
|
@validator('event_presenter_id', always=True)
|
||||||
def event_presenter_id_lookup(cls, v, values, **kwargs):
|
def event_presenter_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('event_presenter_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event_presenter')
|
||||||
if values['event_presenter_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['event_presenter_id_random'], table_name='event_presenter')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('event_session_id', always=True)
|
@validator('event_session_id', always=True)
|
||||||
def event_session_id_lookup(cls, v, values, **kwargs):
|
def event_session_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('event_session_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event_session')
|
||||||
if values['event_session_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['event_session_id_random'], table_name='event_session')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('event_track_id', always=True)
|
@validator('event_track_id', always=True)
|
||||||
def event_track_id_lookup(cls, v, values, **kwargs):
|
def event_track_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('event_track_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event_track')
|
||||||
if values['event_track_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['event_track_id_random'], table_name='event_track')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# NOTE: I kind of give up on this. Handeling this outside of Pydantic and before the data is even attempted to be loaded into the Event_File_Base model. -STI 2021-09-10
|
# NOTE: I kind of give up on this. Handeling this outside of Pydantic and before the data is even attempted to be loaded into the Event_File_Base model. -STI 2021-09-10
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class Event_Person_Base(BaseModel):
|
|||||||
id: Optional[int] = Field(
|
id: Optional[int] = Field(
|
||||||
alias = 'event_person_id'
|
alias = 'event_person_id'
|
||||||
)
|
)
|
||||||
|
|
||||||
account_id_random: Optional[str]
|
account_id_random: Optional[str]
|
||||||
account_id: Optional[int]
|
account_id: Optional[int]
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
from __future__ import annotations
|
|
||||||
import datetime, hashlib, logging, os, pytz, redis, secrets
|
import datetime, hashlib, logging, os, pytz, redis, secrets
|
||||||
|
|
||||||
from typing import Dict, List, Optional, Set, Union
|
from typing import Dict, List, Optional, Set, Union
|
||||||
@@ -11,7 +10,7 @@ from .common_field_schema import base_fields, default_num_bytes
|
|||||||
|
|
||||||
|
|
||||||
class Hosted_File_Base(BaseModel):
|
class Hosted_File_Base(BaseModel):
|
||||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
log.debug(locals())
|
log.debug(locals())
|
||||||
|
|
||||||
id_random: Optional[str] = Field(
|
id_random: Optional[str] = Field(
|
||||||
@@ -20,8 +19,9 @@ class Hosted_File_Base(BaseModel):
|
|||||||
default_factory = lambda:secrets.token_urlsafe(default_num_bytes),
|
default_factory = lambda:secrets.token_urlsafe(default_num_bytes),
|
||||||
)
|
)
|
||||||
id: Optional[int] = Field(
|
id: Optional[int] = Field(
|
||||||
#alias = 'hosted_file_id'
|
alias = 'hosted_file_id'
|
||||||
)
|
)
|
||||||
|
|
||||||
account_id_random: Optional[str]
|
account_id_random: Optional[str]
|
||||||
account_id: Optional[int]
|
account_id: Optional[int]
|
||||||
|
|
||||||
@@ -67,30 +67,22 @@ class Hosted_File_Base(BaseModel):
|
|||||||
|
|
||||||
#@validator('hosted_file_id_random', always=True)
|
#@validator('hosted_file_id_random', always=True)
|
||||||
def hosted_file_id_random_copy(cls, v, values, **kwargs):
|
def hosted_file_id_random_copy(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
|
||||||
log.debug(locals())
|
|
||||||
|
|
||||||
if values['id_random']:
|
if values['id_random']:
|
||||||
return values['id_random']
|
return values['id_random']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('id', always=True)
|
@validator('id', always=True)
|
||||||
def hosted_file_id_lookup(cls, v, values, **kwargs):
|
def hosted_file_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='hosted_file')
|
||||||
if values['id_random']:
|
|
||||||
log.debug(values['id_random'])
|
|
||||||
return redis_lookup_id_random(record_id_random=values['id_random'], table_name='hosted_file')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('account_id', always=True)
|
@validator('account_id', always=True)
|
||||||
def account_id_lookup(cls, v, values, **kwargs):
|
def account_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('account_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='account')
|
||||||
if values['account_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['account_id_random'], table_name='account')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|||||||
Reference in New Issue
Block a user