Working on event person, registration, badge, session, presentation, and presenter create and update. _v3 things

This commit is contained in:
Scott Idem
2021-08-25 16:25:46 -04:00
parent 8ff404e534
commit c93792634a
11 changed files with 372 additions and 74 deletions

View File

@@ -101,12 +101,44 @@ def get_address_rec_list(
# ### BEGIN ### API Address Methods ### create_address_obj() ###
# NOTE: This will create an address.
# Reviewed and updated 2021-08-10
def create_address_obj(address_obj_new:Address_Base):
def create_address_obj(
address_obj_new: Address_Base,
account_id: int|str = None,
for_type: str = None,
for_id: int|str = None,
fail_any: bool = False, # Fail if any thing goes wrong for sub objects
) -> int|bool:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if not address_obj_new:
return False
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
else: return False
if for_id := redis_lookup_id_random(record_id_random=for_id, table_name=for_type): pass
else: return False
log.debug(type(address_obj_new))
if isinstance(address_obj_new, dict):
if account_id:
address_obj_new['account_id'] = account_id
if for_type:
address_obj_new['for_type'] = for_type
if for_id:
address_obj_new['for_id'] = for_id
try:
address_obj_new = Address_Base(**address_obj_new)
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(address_obj_new)
except ValidationError as e:
log.error(e.json())
return False
else:
if account_id:
address_obj_new.account_id = account_id
if for_type:
address_obj_new.for_type = for_type
if for_id:
address_obj_new.for_id = for_id
address_obj_data = address_obj_new.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'created_on', 'updated_on'})
@@ -130,6 +162,7 @@ def update_address_obj(
address_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value.
address_obj_up: Address_Base,
create_sub_obj: bool = False,
fail_any: bool = False, # Fail if any thing goes wrong for sub objects
) -> bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())