General clean up. Work on abstracts and websockets

This commit is contained in:
Scott Idem
2023-03-23 19:12:13 -04:00
parent 430a155b75
commit 224aaed969
8 changed files with 435 additions and 48 deletions

View File

@@ -37,7 +37,7 @@ class Common_Route_Params_No_Account_ID:
limit: int = 10,
offset: int = 0,
by_alias: bool = True,
exclude_unset: bool = True,
exclude_unset: bool = False,
response = None,
):
self.x_account_id = x_account_id
@@ -62,7 +62,7 @@ def common_route_params_no_account_id(
offset: int = 0,
by_alias: bool = True,
exclude_none: Optional[bool] = True,
exclude_unset: bool = True,
exclude_unset: bool = False,
# NOTE: Uncommenting either exclude or include breaks the JSON body format. I do not know why? Should be: {} Becomes this: {"obj_name": {"data_name": "data_value"}} -STI 2022-01-05
# exclude: Optional[list] = [], # Leaving this and include commented out
# include: Optional[list] = [], # Leaving this and exclude commented out
@@ -103,7 +103,7 @@ class Common_Route_Params:
limit: int = 10,
offset: int = 0,
by_alias: bool = True,
exclude_unset: bool = True,
exclude_unset: bool = False,
response = None,
):
self.x_account_id = x_account_id
@@ -127,8 +127,9 @@ def common_route_params(
limit: int = 100,
offset: int = 0,
by_alias: bool = True,
exclude_none: Optional[bool] = True,
exclude_unset: bool = True,
exclude_unset: bool = False,
exclude_defaults: Optional[bool] = False,
exclude_none: Optional[bool] = False,
# NOTE: Uncommenting either exclude or include breaks the JSON body format. I do not know why? Should be: {} Becomes this: {"obj_name": {"data_name": "data_value"}} -STI 2022-01-05
# exclude: Optional[list] = [], # Leaving this and include commented out
# include: Optional[list] = [], # Leaving this and exclude commented out
@@ -169,7 +170,7 @@ class Common_Route_Params_Min:
limit: int = 10,
offset: int = 0,
by_alias: bool = True,
exclude_unset: bool = True,
exclude_unset: bool = False,
response = None,
):
self.x_account_id = x_account_id
@@ -195,7 +196,7 @@ def common_route_params_min(
offset: int = 0,
by_alias: bool = True,
exclude_none: Optional[bool] = True,
exclude_unset: bool = True,
exclude_unset: bool = False,
# NOTE: Uncommenting either exclude or include breaks the JSON body format. I do not know why? Should be: {} Becomes this: {"obj_name": {"data_name": "data_value"}} -STI 2022-01-05
# exclude: Optional[list] = [], # Leaving this and include commented out
# include: Optional[list] = [], # Leaving this and exclude commented out

View File

@@ -7,10 +7,10 @@ from app.db_sql import redis_lookup_id_random, sql_delete, sql_insert, sql_selec
from app.lib_general import log, logging, logger_reset
# from app.methods.event_abstract_tracking_methods import get_event_abstract_tracking_rec_list, load_event_abstract_tracking_obj
# from app.methods.event_person_methods import load_event_person_obj
from app.methods.event_person_methods import load_event_person_obj
from app.models.common_field_schema import default_num_bytes
from app.models.event_abstract_models import Event_Abstract_Base
from app.models.event_abstract_models import Event_Abstract_Ext, Event_Abstract_In
# ### BEGIN ### API Event Abstract Methods ### load_event_abstract_obj() ###
@@ -26,6 +26,7 @@ def load_event_abstract_obj(
inc_event_file_list: bool = False,
inc_event_person: bool = False,
inc_event_person_profile: bool = False,
inc_event_presentation_list: bool = False,
inc_event_presenter_list: bool = False,
inc_hosted_file: bool = False,
@@ -35,8 +36,8 @@ def load_event_abstract_obj(
by_alias: bool = True,
exclude_unset: bool = True,
model_as_dict: bool = False,
) -> Event_Abstract_Base|dict|bool:
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
) -> Event_Abstract_Ext|dict|bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# if event_abstract_id := redis_lookup_id_random(record_id_random=event_abstract_id, table_name='event_abstract'): pass
@@ -46,7 +47,7 @@ def load_event_abstract_obj(
else: return False
try:
event_abstract_obj = Event_Abstract_Base(**event_abstract_rec)
event_abstract_obj = Event_Abstract_Ext(**event_abstract_rec)
log.debug(event_abstract_obj)
except ValidationError as e:
log.error(e.json())
@@ -99,7 +100,7 @@ def load_event_abstract_obj(
# inc_address = inc_address,
# inc_contact = inc_contact,
# inc_event_abstract = inc_event_abstract,
# inc_event_person_profile = inc_event_person_profile,
inc_event_person_profile = inc_event_person_profile,
# inc_event_registration = inc_event_registration,
# inc_person = inc_person,
# inc_user = inc_user,
@@ -226,10 +227,79 @@ def get_event_abstract_rec_list(
# ### BEGIN ### API Event Abstract Methods ### create_update_event_abstract_obj() ###
# Updated 2023-03-20
# Updated 2023-03-22
@logger_reset
def create_update_event_abstract_obj(
event_abstract_dict_obj: Event_Abstract_Base|dict,
event_abstract_obj: Event_Abstract_In,
event_abstract_id: int = None,
event_id: int = None,
event_person_id: int = None,
create_sub_obj: bool = False,
fail_any: bool = False, # Fail if any thing goes wrong for sub objects
return_outline: bool = False,
) -> int|bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
log.info('Checking requirements...')
if event_abstract_id:
log.info(f'Got: event_abstract_id={event_abstract_id}; Update existing Event Abstract')
event_abstract_obj.id = event_abstract_id
elif event_id and event_person_id:
log.info(f'Got: event_id={event_id}; event_person_id={event_person_id}; Create Event Abstract')
event_abstract_obj.event_id = event_id
event_abstract_obj.event_person_id = event_person_id
else:
return False
log.debug(type(event_abstract_obj))
log.debug(event_abstract_obj
)
event_abstract_dict = event_abstract_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'event_file_list', 'event_person', 'event_person_list', 'event_presenter_list', 'created_on', 'updated_on'})
if event_abstract_id:
if event_abstract_dict_up_result := sql_update(data=event_abstract_dict, table_name='event_abstract', rm_id_random=True):
log.info(f'Event Abstract updated. event_abstract_id={event_abstract_id}')
pass
else:
log.warning(f'Event Abstract not updated. event_abstract_id={event_abstract_id}')
log.debug(event_abstract_dict_up_result)
return False
log.debug(event_abstract_dict_up_result)
else:
if event_abstract_dict_in_result := sql_insert(data=event_abstract_dict, table_name='event_abstract', rm_id_random=True, id_random_length=None):
log.info(f'Event Abstract created. event_abstract_id={event_abstract_dict_in_result}')
else:
log.warning(f'Event Abstract not created.')
log.debug(event_abstract_dict_in_result)
return False
log.debug(event_abstract_dict_in_result)
event_abstract_id = event_abstract_dict_in_result # False, None, integer
event_abstract_outline = {}
event_abstract_outline['event_id'] = event_id
event_abstract_outline['event_abstract_id'] = event_abstract_id
event_abstract_outline['event_person_id'] = event_person_id
# event_abstract_outline['event_file_count'] = event_file_count
if return_outline:
log.debug(f'Returning the Event Abstract Outline: {event_abstract_outline}')
return event_abstract_outline
else:
log.debug(f'Returning the Event Abstract ID: {event_abstract_id}')
return event_abstract_id
# ### END ### API Event Abstract Methods ### create_update_event_abstract_obj() ###
# ### BEGIN ### API Event Abstract Methods ### create_update_event_abstract_obj_old() ###
# Updated 2023-03-20
@logger_reset
def create_update_event_abstract_obj_old(
event_abstract_dict_obj: Event_Abstract_In|dict,
event_abstract_id: int|str = None,
event_id: int|str = None,
event_person_id: int|str = None,
@@ -286,7 +356,7 @@ def create_update_event_abstract_obj(
if event_person_id:
event_abstract_dict['event_person_id'] = event_person_id
try:
event_abstract_obj = Event_Abstract_Base(**event_abstract_dict)
event_abstract_obj = Event_Abstract_In(**event_abstract_dict)
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_abstract_obj)
except ValidationError as e:
@@ -360,4 +430,63 @@ def create_update_event_abstract_obj(
else:
log.debug(f'Returning the Event Abstract ID: {event_abstract_id}')
return event_abstract_id
# ### END ### API Event Abstract Methods ### create_update_event_abstract_obj() ###
# ### END ### API Event Abstract Methods ### create_update_event_abstract_obj_old() ###
# ### BEGIN ### API Event Abstract Methods ### remove_event_abstract_obj() ###
# Updated 2023-03-22
@logger_reset
def remove_event_abstract_obj(
event_abstract_id: int,
method: None|str = None,
log_lvl: int = logging.DEBUG, # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
) -> bool|None:
log.setLevel(log_lvl)
if method is None or method == 'disable':
data = {'enable': False}
if event_abstract_dict_up_result := sql_update(
table_name = 'event_abstract',
record_id = event_abstract_id,
data = data,
log_lvl = log_lvl,
):
log.info(f'Event Abstract was disabled.')
return True
else:
log.warning(f'Event Abstract not disabled.')
return event_abstract_dict_up_result # False or None
elif method == 'delete':
if event_abstract_dict_del_result := sql_delete(
table_name = 'event_abstract',
record_id = event_abstract_id,
log_lvl = log_lvl,
):
log.info(f'Event Abstract was deleted.')
return True
else:
log.warning(f'Event Abstract not deleted.')
return event_abstract_dict_del_result # False or None
elif method == 'hide':
data = {'hide': True}
if event_abstract_dict_up_result := sql_update(
table_name = 'event_abstract',
record_id = event_abstract_id,
data = data,
log_lvl = log_lvl,
):
log.info(f'Event Abstract was hidden.')
return True
else:
log.warning(f'Event Abstract not hidden.')
return event_abstract_dict_up_result # False or None
else:
log.error('We should not be here. Something went wrong in remove_event_abstract_obj()!')
return False
# ### END ### API Event Abstract Methods ### remove_event_abstract_obj() ###

View File

@@ -6,7 +6,67 @@ from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationEr
from app.db_sql import redis_lookup_id_random
from app.lib_general import log, logging
from app.common_field_schema import base_fields, default_num_bytes
# from app.common_field_schema import base_fields, default_num_bytes
class Core_Std_Obj_Base(BaseModel):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(
alias = 'obj_id_random', # Not the DB field name
)
id: Optional[int] = Field(
alias = 'obj_id' # Not the DB field name
)
# id: int
oid: Optional[str] = None
otype: Optional[str] = None
code: Optional[str] = None
name: Optional[str] = None
# Including JSON data
data_json: Optional[Json]
other_json: Optional[Json]
meta_json: Optional[Json]
# For moderation:
enable: Optional[bool] # Manager override to fully enable/disable
enable_from: Optional[datetime.datetime] = None
enable_to: Optional[datetime.datetime] = None
status: Optional[int]
review: Optional[bool] # ready for review or not ready for review
approve: Optional[bool] # approved or not approved
ready: Optional[bool]
archive: Optional[bool]
hide: Optional[bool]
priority: Optional[bool]
sort: Optional[int]
group: Optional[str]
notes: Optional[str]
xyz: Optional[str]
created_on: Optional[datetime.datetime] = None
updated_on: Optional[datetime.datetime] = None
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
@validator('oid', always=True)
def id_random_to_oid(cls, v, values, **kwargs):
if isinstance(v, str):
log.info('Got oid value!')
return v
elif id_random := values.get('id_random'):
log.info('Got id_random value!')
return id_random
# return redis_lookup_id_random(record_id_random=id_random, table_name=otype)
return None
class Core_Object_Base(BaseModel):

View File

@@ -8,7 +8,8 @@ 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.core_object_models import Core_Std_Obj_Base
# from app.models.event_models import Event_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_presenter_models import Event_Presenter_Base # This creates an import loop
@@ -65,13 +66,15 @@ class Event_Abstract_Base(BaseModel):
group: Optional[str]
notes: Optional[str]
created_on: Optional[datetime.datetime] = None
updated_on: Optional[datetime.datetime] = None
# Including other related objects
#event: Optional[Event_Base]
# event: Optional[Event_Base]
event_file_list: Optional[list] # Optional[Event_File_Base]
# event_person: Optional[Event_Person_Base]
event_person: Optional[dict]
# event_presentation: Optional[Event_Presentation_Base]
#event_presenter: Optional[Event_Presenter_Base] # This creates an import loop
event_presenter_list: Optional[list] # Optional[Event_Presenter_Base]
@@ -138,3 +141,137 @@ class Event_Abstract_Base(BaseModel):
allow_population_by_field_name = True
fields = base_fields
# ### END ### API Event Abstract Models ### Event_Abstract_Base() ###
# ### BEGIN ### API Event Abstract Models ### Event_Abstract_Base() ###
# Update 2023-03-22
class Event_Abstract_Base_New(Core_Std_Obj_Base):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# id_random: Optional[str] = Field(
# alias = 'event_abstract_id_random',
# )
event_id_random: Optional[str]
event_id: Optional[int]
event_person_id: Optional[int]
event_session_id: Optional[int]
event_person_id_random: Optional[str]
event_presentation_id_random: Optional[str]
event_presenter_id_random: Optional[str]
event_session_id_random: Optional[str]
# event_track_id_random: Optional[str]
poc_event_person_id_random: Optional[str] # Maybe change this to primary_event_person?
description: Optional[str]
abstract: Optional[str]
class Config:
underscore_attrs_are_private = True
allow_population_by_field_name = True
fields = base_fields
# ### END ### API Event Abstract Models ### Event_Abstract_Base() ###
# ### BEGIN ### API Event Abstract Models ### Event_Abstract_In() ###
# Update 2023-03-22
class Event_Abstract_In(Event_Abstract_Base_New):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id: Optional[int] = Field(
alias = 'event_abstract_id'
)
event_id: Optional[int]
event_person_id: Optional[int]
event_session_id: Optional[int]
@validator('id', always=True)
def event_abstract_id_lookup(cls, v, values, **kwargs):
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='event_abstract')
return None
@validator('event_id', always=True)
def event_id_lookup(cls, v, values, **kwargs):
if isinstance(v, int) and v > 0: return v
elif id_random := values.get('event_id_random'):
return redis_lookup_id_random(record_id_random=id_random, table_name='event')
return None
@validator('event_person_id', always=True)
def event_person_id_lookup(cls, v, values, **kwargs):
if isinstance(v, int) and v > 0: return v
elif id_random := values.get('event_person_id_random'):
return redis_lookup_id_random(record_id_random=id_random, table_name='event_person')
return None
# @validator('event_presentation_id', always=True)
# def event_presentation_id_lookup(cls, v, values, **kwargs):
# if isinstance(v, int) and v > 0: return v
# elif id_random := values.get('event_presentation_id_random'):
# return redis_lookup_id_random(record_id_random=id_random, table_name='event_presentation')
# return None
# @validator('event_presenter_id', always=True)
# def event_presenter_id_lookup(cls, v, values, **kwargs):
# if isinstance(v, int) and v > 0: return v
# elif id_random := values.get('event_presenter_id_random'):
# return redis_lookup_id_random(record_id_random=id_random, table_name='event_presenter')
# return None
@validator('event_session_id', always=True)
def event_session_id_lookup(cls, v, values, **kwargs):
if isinstance(v, int) and v > 0: return v
elif id_random := values.get('event_session_id_random'):
return redis_lookup_id_random(record_id_random=id_random, table_name='event_session')
return None
# @validator('poc_event_person_id', always=True)
# def poc_event_person_id_lookup(cls, v, values, **kwargs):
# log.setLevel(logging.WARNING)
# log.debug(locals())
# if values['poc_event_person_id_random']:
# return redis_lookup_id_random(record_id_random=values['poc_event_person_id_random'], table_name='poc_event_person')
# return None
# ### END ### API Event Abstract Models ### Event_Abstract_In() ###
# ### BEGIN ### API Event Abstract Models ### Event_Abstract_Ext() ###
# Update 2023-03-22
class Event_Abstract_Ext(Event_Abstract_Base_New):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# Including other related objects
# event: Optional[Event_Base]
event_file_list: Optional[list] # Optional[Event_File_Base]
# from app.models.event_person_models import Event_Person_Base
# event_person: Optional[Event_Person_Base]
event_person: Optional[dict]
# event_presentation: Optional[Event_Presentation_Base]
#event_presenter: Optional[Event_Presenter_Base] # This creates an import loop
# event_presenter_list: Optional[list] # Optional[Event_Presenter_Base]
# event_session: Optional[Event_Session_Base]
# event_track: Optional[Event_Track_Base]
# poc_event_person: Optional[Event_Person_Base] # Maybe change this to primary_event_person?
# poc_person: Optional[Person_Base] # Maybe change this to primary_person?
# ### END ### API Event Abstract Models ### Event_Abstract_Ext() ###

View File

@@ -8,7 +8,7 @@ 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 # Causes an import loop
from app.models.event_abstract_models import Event_Abstract_Base
# from app.models.event_abstract_models import Event_Abstract_Base
from app.models.event_badge_models import Event_Badge_Base
# from app.models.event_exhibit_tracking_models import Event_Exhibit_Tracking_Base # Causes an import loop
from app.models.event_person_profile_models import Event_Person_Profile_Base
@@ -114,7 +114,7 @@ class Event_Person_Base(BaseModel):
# Including other related objects
# event: Optional[Event_Base] # Causes an import loop
event_abstract_list: Optional[list[Event_Abstract_Base]] # Use event_person_detail table. An event_person record can be linked to one or more abstracts
# event_abstract_list: Optional[list[Event_Abstract_Base]] # Use event_person_detail table. An event_person record can be linked to one or more abstracts
event_badge: Optional[Event_Badge_Base] # Default attendee badge
event_badge_vendor: Optional[Event_Badge_Base] # Additional vendor badge
event_badge_vip: Optional[Event_Badge_Base] # Additional VIP badge

View File

@@ -39,8 +39,10 @@ def mk_resp(
status_name: str = '',
success: bool = True,
details: str = '',
include: dict = None,
exclude: dict = None,
by_alias: bool = True,
exclude_unset: bool = True,
exclude_unset: bool = False,
response: Response = None
) -> dict:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
@@ -63,7 +65,7 @@ def mk_resp(
data_out = { 'result': data }
else: # Assuming it is still and object. This should be improved. Example model type: "<class 'app.models.account_models.Account_Base'>"
log.info('Data type is other')
data_out = data.dict(by_alias=by_alias, exclude_unset=exclude_unset)
data_out = data.dict(include=include, exclude=exclude, by_alias=by_alias, exclude_unset=exclude_unset)
# log.debug(data_out)
resp_body = {}

View File

@@ -9,9 +9,9 @@ from app.db_sql import sql_insert, sql_update, sql_insert_or_update, sql_select,
from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
from app.methods.event_abstract_methods import create_update_event_abstract_obj, load_event_abstract_obj, get_event_abstract_rec_list
from app.methods.event_abstract_methods import create_update_event_abstract_obj, load_event_abstract_obj, get_event_abstract_rec_list, remove_event_abstract_obj
from app.models.event_abstract_models import Event_Abstract_Base
from app.models.event_abstract_models import Event_Abstract_In
from app.models.response_models import Resp_Body_Base, mk_resp
@@ -19,13 +19,19 @@ router = APIRouter()
# ### BEGIN ### API Event Abstract ### post_event_abstract_obj() ###
# Updated 2023-03-20
# Updated 2023-03-22
@router.post('/event/abstract', response_model=Resp_Body_Base)
async def post_event_abstract_obj(
event_abstract_obj: Event_Abstract_Base,
create_sub_obj: bool = False,
fail_any: bool = True, # Fail if any thing goes wrong for sub objects
event_abstract_obj: Event_Abstract_In,
event_id: str = Query(..., min_length=11, max_length=22),
event_person_id: str = Query(..., min_length=11, max_length=22),
# create_sub_obj: bool = False,
# fail_any: bool = True, # Fail if any thing goes wrong for sub objects
return_obj: bool = True,
inc_event_file_list: bool = False,
inc_event_person: bool = False,
inc_event_presentation_list: bool = False,
inc_event_presenter_list: bool = False,
@@ -34,12 +40,19 @@ async def post_event_abstract_obj(
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if event_id := redis_lookup_id_random(record_id_random=event_id, table_name='event'): pass
else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The Event ID was invalid or not found.')
if event_person_id := redis_lookup_id_random(record_id_random=event_person_id, table_name='event_person'): pass
else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The Event Person ID was invalid or not found.')
# There should probably be a check for the event ID before calling the create function?
if create_event_abstract_obj_result := create_update_event_abstract_obj(
event_abstract_dict_obj = event_abstract_obj,
event_abstract_obj = event_abstract_obj,
event_id = event_abstract_obj.event_id,
create_sub_obj = create_sub_obj,
fail_any = fail_any,
event_person_id = event_abstract_obj.event_person_id,
# create_sub_obj = create_sub_obj,
# fail_any = fail_any,
return_outline = False,
): pass
else: return mk_resp(data=False, status_code=400, response=commons.response, status_message='The event abstract was not created. Check the field names and data types.')
@@ -49,6 +62,8 @@ async def post_event_abstract_obj(
if return_obj:
if load_event_abstract_obj_result := load_event_abstract_obj(
event_abstract_id = event_abstract_id,
inc_event_file_list = inc_event_file_list,
inc_event_person = inc_event_person,
inc_event_presentation_list = inc_event_presentation_list,
inc_event_presenter_list = inc_event_presenter_list,
):
@@ -68,14 +83,18 @@ async def post_event_abstract_obj(
# ### BEGIN ### API Event Abstract ### patch_event_abstract_obj() ###
# Updated 2023-03-20
# Updated 2023-03-22
@router.patch('/event/abstract/{event_abstract_id}', response_model=Resp_Body_Base)
async def patch_event_abstract_obj(
event_abstract_obj: Event_Abstract_Base,
event_abstract_obj: Event_Abstract_In,
event_abstract_id: str = Query(..., min_length=11, max_length=22),
create_sub_obj: bool = False,
fail_any: bool = True, # Fail if any thing goes wrong for sub objects
# create_sub_obj: bool = False,
# fail_any: bool = True, # Fail if any thing goes wrong for sub objects
return_obj: bool = True,
inc_event_file_list: bool = False,
inc_event_person: bool = False,
inc_event_presentation_list: bool = False,
inc_event_presenter_list: bool = False,
@@ -85,14 +104,13 @@ async def patch_event_abstract_obj(
log.debug(locals())
if event_abstract_id := redis_lookup_id_random(record_id_random=event_abstract_id, table_name='event_abstract'): pass
else: return mk_resp(data=None, status_code=404, response=commons.response)
else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The Event Abstract ID was invalid or not found.')
if update_event_abstract_obj_result := create_update_event_abstract_obj(
event_abstract_dict_obj = event_abstract_obj,
event_abstract_obj = event_abstract_obj,
event_abstract_id = event_abstract_id,
event_id = event_abstract_obj.event_id,
create_sub_obj = create_sub_obj,
fail_any = fail_any,
# create_sub_obj = create_sub_obj,
# fail_any = fail_any,
return_outline = False,
): pass
else: return mk_resp(data=False, status_code=400, response=commons.response, status_message='The event abstract was not created. Check the field names and data types.')
@@ -101,6 +119,8 @@ async def patch_event_abstract_obj(
if return_obj:
if load_event_abstract_obj_result := load_event_abstract_obj(
event_abstract_id = event_abstract_id,
inc_event_file_list = inc_event_file_list,
inc_event_person = inc_event_person,
inc_event_presentation_list = inc_event_presentation_list,
inc_event_presenter_list = inc_event_presenter_list,
):
@@ -119,13 +139,14 @@ async def patch_event_abstract_obj(
# ### BEGIN ### API Event Abstract ### get_event_abstract_obj() ###
# Updated 2023-03-20
# Updated 2023-03-22
@router.get('/event/abstract/{event_abstract_id}', response_model=Resp_Body_Base)
async def get_event_abstract_obj(
event_abstract_id: str = Query(..., min_length=11, max_length=22),
inc_event_file_list: bool = False,
inc_event_person: bool = False,
# inc_event_person_profile: bool = False,
inc_event_person_profile: bool = True,
inc_event_presentation_list: bool = False,
inc_event_presenter_list: bool = False,
@@ -135,7 +156,7 @@ async def get_event_abstract_obj(
commons: Common_Route_Params = Depends(common_route_params),
):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# time.sleep(.5)
@@ -153,11 +174,15 @@ async def get_event_abstract_obj(
hidden = hidden, # hidden, not_hidden, all
review = review, # ready, not_ready, all
inc_event_file_list = inc_event_file_list,
inc_event_person = inc_event_person,
inc_event_person_profile = inc_event_person_profile,
inc_event_presentation_list = inc_event_presentation_list,
inc_event_presenter_list = inc_event_presenter_list,
):
log.info('Loading successful. Returning result')
event_abstract_obj_result.xyz = 'asdf!!!'
log.debug(event_abstract_obj_result)
return mk_resp(data=event_abstract_obj_result, response=commons.response) # Success
elif isinstance(event_abstract_obj_result, list) or event_abstract_obj_result is None: # Empty list or None
log.info('No results')
@@ -166,3 +191,35 @@ async def get_event_abstract_obj(
log.warning('Likely bad request')
return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
# ### END ### API Event Abstract ### get_event_abstract_obj() ###
# ### BEGIN ### API Event Exhibit Tracking ### delete_event_abstract_obj() ###
# Updated 2023-03-22
@router.delete('/event/abstract/{event_abstract_id}', response_model=Resp_Body_Base)
def delete_event_abstract_obj(
event_abstract_id: str = Query(..., min_length=11, max_length=22),
method: str = None, # None, delete, disable, hide
commons: Common_Route_Params = Depends(common_route_params),
):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# ### SECTION ### Secondary data validation
if event_abstract_id := redis_lookup_id_random(record_id_random=event_abstract_id, table_name='event_abstract'): pass
else: return mk_resp(data=None, status_code=404, response=response, status_message='The Event Abstract ID was invalid or not found.')
if event_abstract_obj_result := remove_event_abstract_obj(
event_abstract_id = event_abstract_id,
method = method,
):
log.info('Delete successful. Returning True')
return mk_resp(data=True, response=response) # Success
elif event_abstract_obj_result is None: # None
log.info('No results')
return mk_resp(data=None, status_code=404, response=response) # Not Found
else:
log.warning('Likely bad request')
return mk_resp(data=False, status_code=400, response=response) # Bad Request
# ### END ### API Event Exhibit Tracking ### delete_event_abstract_obj() ###

View File

@@ -372,6 +372,7 @@ async def delete_event_file_obj(
return mk_resp(data=True, response=commons.response)
# ### END ### API Event File ### delete_event_file_obj() ###
# ### BEGIN ### API Event File ### delete_event_file_obj_v2() ###
# Updated 2022-08-18
@router.delete('/event/file/{event_file_id}/v2', response_model=Resp_Body_Base)
@@ -387,7 +388,7 @@ async def delete_event_file_obj_v2(
log.debug(locals())
if event_file_id := redis_lookup_id_random(record_id_random=event_file_id, table_name='event_file'): pass
else: return mk_resp(data=None, status_code=404, response=commons.response)
else: return mk_resp(data=None, status_code=404, response=commons.response, status_message=f'The Event File ID was invalid or not found. event_file_id={event_file_id}')
if event_file_obj := load_event_file_obj(
event_file_id = event_file_id,
@@ -415,7 +416,7 @@ async def delete_event_file_obj_v2(
link_to_type = for_type
link_to_id = for_id
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(f'Event File ID: {event_file_id}')
if handle_delete_event_file(event_file_id=event_file_id):
if delete_hosted_file: pass
@@ -459,4 +460,4 @@ async def delete_event_file_obj_v2(
# else: return mk_resp(data=False, status_code=500, response=commons.response) # Internal Server Error
# return mk_resp(data=True, response=commons.response)
# ### END ### API Event File ### delete_event_file_obj_v2() ###
# ### END ### API Event File ### delete_event_file_obj_v2() ###