Work on event patch and list, account list, and minor changes
This commit is contained in:
@@ -9,7 +9,7 @@ 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.account_methods import load_account_obj, load_account_obj_membership_type
|
||||
from app.methods.account_methods import get_account_rec_list, load_account_obj
|
||||
from app.methods.account_cfg_methods import load_account_cfg_obj
|
||||
from app.methods.event_methods import get_event_rec_list, load_event_obj
|
||||
# from app.methods.membership_group_methods import get_membership_group_rec_list, load_membership_group_obj
|
||||
@@ -76,27 +76,80 @@ async def patch_account_obj(
|
||||
return result
|
||||
|
||||
|
||||
# ### BEGIN ### API Account ### get_account_obj_li() ###
|
||||
# Updated 2021-09-28
|
||||
@router.get('/list', response_model=Resp_Body_Base)
|
||||
async def get_account_obj_li(
|
||||
for_obj_type: Optional[str] = Query(None, min_length=2, max_length=50),
|
||||
for_obj_id: Optional[str] = Query(None, min_length=1, max_length=22),
|
||||
# inc_address: bool = False,
|
||||
# inc_address_list: bool = False,
|
||||
inc_archive_list: bool = False,
|
||||
# inc_contact: bool = False,
|
||||
# inc_contact_list: bool = False,
|
||||
inc_event_list: bool = False,
|
||||
inc_hosted_file_list: bool = False,
|
||||
inc_journal_list: bool = False,
|
||||
inc_membership_person_list: bool = False,
|
||||
inc_order_list: bool = False,
|
||||
inc_organization_list: bool = False,
|
||||
inc_page_list: bool = False,
|
||||
inc_person_list: bool = False,
|
||||
inc_post_list: bool = False,
|
||||
inc_product_list: bool = False,
|
||||
inc_site_list: bool = False,
|
||||
inc_site_domain_list: bool = False,
|
||||
inc_user_list: bool = False,
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
return_obj: bool = True,
|
||||
limit: int = 25,
|
||||
enabled: str = 'enabled',
|
||||
by_alias: bool = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
obj_type = 'account'
|
||||
result = get_obj_li_template(
|
||||
obj_type=obj_type,
|
||||
for_obj_type=for_obj_type,
|
||||
for_obj_id=for_obj_id,
|
||||
by_alias=True,
|
||||
exclude_unset=True,
|
||||
)
|
||||
return result
|
||||
# Updated 2021-09-28
|
||||
if account_rec_list_result := get_account_rec_list(
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
account_result_list = []
|
||||
for account_rec in account_rec_list_result:
|
||||
if load_account_result := load_account_obj(
|
||||
account_id = account_rec.get('account_id', None),
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
# model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
# inc_address = inc_address,
|
||||
# inc_address_list = inc_address_list,
|
||||
# inc_archive_list = inc_archive_list,
|
||||
# inc_contact = inc_contact,
|
||||
# inc_contact_list = inc_contact_list,
|
||||
inc_event_list = inc_event_list,
|
||||
# inc_hosted_file_list = inc_hosted_file_list,
|
||||
# inc_journal_list = inc_journal_list,
|
||||
inc_membership_person_list = inc_membership_person_list,
|
||||
# inc_order_list = inc_order_list,
|
||||
# inc_organization_list = inc_organization_list,
|
||||
inc_page_list = inc_page_list,
|
||||
inc_person_list = inc_person_list,
|
||||
inc_post_list = inc_post_list,
|
||||
# inc_product_list = inc_product_list,
|
||||
inc_site_list = inc_site_list,
|
||||
inc_site_domain_list = inc_site_domain_list,
|
||||
inc_user_list = inc_user_list,
|
||||
):
|
||||
account_result_list.append(load_account_result)
|
||||
else:
|
||||
account_result_list.append(None)
|
||||
response_data = account_result_list
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
|
||||
|
||||
# ### BEGIN ### API Account ### get_account_obj_new() ###
|
||||
@@ -185,8 +238,7 @@ async def get_account_obj_new(
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else:
|
||||
return mk_resp(data=None, status_code=404)
|
||||
else: return mk_resp(data=None, status_code=404)
|
||||
|
||||
if account_result := load_account_obj(
|
||||
account_id = account_id,
|
||||
@@ -281,112 +333,6 @@ async def get_account_obj_new(
|
||||
# ### END ### API Account ### get_account_obj_new() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Account ### get_account_obj_event_list() ###
|
||||
# Working well as of 2021-06-30. Using as a template for other routes.
|
||||
@router.get('/{account_id}/event/list', response_model=Resp_Body_Base)
|
||||
async def get_account_obj_event_list(
|
||||
account_id: str = Query(..., min_length=1, max_length=22),
|
||||
limit: int = 500, # For now this covers any included objects or object lists
|
||||
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
||||
conference: bool = False, # Events with badges, sessions, presentations, presenters, registration, etc
|
||||
# inc_account_cfg: bool = False,
|
||||
inc_address: bool = False, # Under event and under contact
|
||||
# inc_address_location: bool = False,
|
||||
inc_contact: bool = False,
|
||||
# inc_event_abstract_list: bool = False,
|
||||
# inc_event_badge_list: bool = False,
|
||||
inc_event_cfg: bool = False,
|
||||
# inc_event_device_list: bool = False,
|
||||
# inc_event_exhibit_list: bool = False,
|
||||
inc_event_file_list: bool = False,
|
||||
# inc_event_location: bool = False,
|
||||
inc_event_location_list: bool = False,
|
||||
# inc_event_person: bool = False,
|
||||
inc_event_person_list: bool = False,
|
||||
inc_event_presentation_list: bool = False,
|
||||
# inc_event_presenter_cat: bool = False,
|
||||
inc_event_presenter_list: bool = False,
|
||||
# inc_event_registration_cfg: bool = False,
|
||||
# inc_event_registration_list: bool = False,
|
||||
inc_event_session_list: bool = False,
|
||||
# inc_event_track: bool = False,
|
||||
# inc_event_track_list: bool = False,
|
||||
# inc_order_list: bool = False,
|
||||
inc_organization: bool = False,
|
||||
inc_person: bool = False,
|
||||
inc_poc_event_person: bool = False,
|
||||
inc_product: bool = False,
|
||||
inc_product_list: bool = False,
|
||||
inc_user: bool = False,
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else: return mk_resp(data=None, status_code=404)
|
||||
|
||||
response_data = None
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
|
||||
# Updated 2021-06-30
|
||||
if event_rec_list_result := get_event_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
conference = conference,
|
||||
):
|
||||
event_result_list = []
|
||||
for event_rec in event_rec_list_result:
|
||||
if load_event_result := load_event_obj(
|
||||
event_id = event_rec.get('event_id', None),
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
# model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
# inc_event_abstract_list = inc_event_abstract_list,
|
||||
# inc_event_badge_list = inc_event_badge_list,
|
||||
inc_event_cfg = inc_event_cfg,
|
||||
# inc_event_device_list = inc_event_device_list,
|
||||
# inc_event_exhibit_list = inc_event_exhibit_list,
|
||||
inc_event_file_list = inc_event_file_list,
|
||||
# inc_event_location = inc_event_location,
|
||||
inc_event_location_list = inc_event_location_list,
|
||||
# inc_event_person = inc_event_person,
|
||||
inc_event_person_list = inc_event_person_list,
|
||||
inc_event_presentation_list = inc_event_presentation_list,
|
||||
# inc_event_presenter_cat = inc_event_presenter_cat,
|
||||
inc_event_presenter_list = inc_event_presenter_list,
|
||||
# inc_event_registration_cfg = inc_event_registration_cfg,
|
||||
# inc_event_registration_list = inc_event_registration_list,
|
||||
inc_event_session_list = inc_event_session_list,
|
||||
# inc_event_track = inc_event_track,
|
||||
# inc_event_track_list = inc_event_track_list,
|
||||
# inc_order_list = inc_order_list,
|
||||
inc_organization = inc_organization,
|
||||
inc_person = inc_person,
|
||||
# inc_product = inc_product,
|
||||
# inc_product_list = inc_product_list,
|
||||
inc_user = inc_user,
|
||||
):
|
||||
event_result_list.append(load_event_result)
|
||||
else:
|
||||
event_result_list.append(None)
|
||||
response_data = event_result_list
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
# ### END ### API Account ### get_account_obj_event_list() ###
|
||||
|
||||
|
||||
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def delete_account_obj(
|
||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
||||
|
||||
@@ -42,72 +42,70 @@ async def post_event_obj(
|
||||
return result
|
||||
|
||||
|
||||
@router.patch('/event/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def patch_event_obj(
|
||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
||||
obj: Event_Base = None,
|
||||
x_account_id: Optional[str] = Header(..., ),
|
||||
return_obj: Optional[bool] = True,
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
# @router.patch('/event/{obj_id}', response_model=Resp_Body_Base)
|
||||
# async def patch_event_obj(
|
||||
# obj_id: str = Query(..., min_length=1, max_length=22),
|
||||
# obj: Event_Base = None,
|
||||
# x_account_id: Optional[str] = Header(..., ),
|
||||
# return_obj: Optional[bool] = True,
|
||||
# by_alias: Optional[bool] = True,
|
||||
# exclude_unset: Optional[bool] = True,
|
||||
# response: Response = Response,
|
||||
# ):
|
||||
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
obj_type = 'event'
|
||||
obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
|
||||
obj_data_dict['id'] = redis_lookup_id_random(record_id_random=obj_id, table_name=obj_type)
|
||||
obj_data_dict['id_random'] = obj_id
|
||||
result = patch_obj_template(
|
||||
obj_type=obj_type,
|
||||
data=obj_data_dict,
|
||||
obj_id=obj_id,
|
||||
return_obj=True,
|
||||
by_alias=True,
|
||||
exclude_unset=True,
|
||||
)
|
||||
return result
|
||||
# obj_type = 'event'
|
||||
# obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
|
||||
# obj_data_dict['id'] = redis_lookup_id_random(record_id_random=obj_id, table_name=obj_type)
|
||||
# obj_data_dict['id_random'] = obj_id
|
||||
# result = patch_obj_template(
|
||||
# obj_type=obj_type,
|
||||
# data=obj_data_dict,
|
||||
# obj_id=obj_id,
|
||||
# return_obj=True,
|
||||
# by_alias=True,
|
||||
# exclude_unset=True,
|
||||
# )
|
||||
# return result
|
||||
|
||||
|
||||
# ### BEGIN ### API Event ### patch_event_json() ###
|
||||
@router.patch('/event/{event_id}/json', response_model=Resp_Body_Base)
|
||||
async def patch_event_json(
|
||||
# ### BEGIN ### API Event ### patch_event() ###
|
||||
@router.patch('/event/{event_id}', response_model=Resp_Body_Base)
|
||||
async def patch_event(
|
||||
event_obj: Event_Base,
|
||||
event_id: str = Query(..., min_length=1, max_length=22),
|
||||
event_id: str = Query(..., min_length=11, max_length=22),
|
||||
create_sub_obj: bool = False,
|
||||
x_account_id: Optional[str] = Header(..., ),
|
||||
return_obj: Optional[bool] = True,
|
||||
inc_event_cfg: bool = False,
|
||||
by_alias: Optional[bool] = True,
|
||||
include: Optional[list] = [],
|
||||
exclude: Optional[list] = [],
|
||||
exclude_unset: Optional[bool] = True,
|
||||
exclude_none: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.DEBUG) # 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)
|
||||
else: return mk_resp(data=None, status_code=404)
|
||||
|
||||
if event_obj_up_result := update_event_obj(
|
||||
event_id=event_id,
|
||||
event_obj_up=event_obj,
|
||||
create_sub_obj=create_sub_obj,
|
||||
event_id = event_id,
|
||||
event_obj_up = event_obj,
|
||||
create_sub_obj = create_sub_obj,
|
||||
):
|
||||
|
||||
log.debug(event_obj_up_result)
|
||||
if return_obj:
|
||||
event_obj = load_event_obj(event_id=event_id)
|
||||
event_obj = load_event_obj(event_id=event_id, inc_event_cfg=inc_event_cfg)
|
||||
event_dict = event_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
return mk_resp(data=event_dict)
|
||||
else:
|
||||
return mk_resp(data=event_obj_up_result)
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response) # Bad Request
|
||||
# ### END ### API Event ### patch_event_json() ###
|
||||
# ### END ### API Event ### patch_event() ###
|
||||
|
||||
|
||||
# @router.get('/event/list', response_model=Resp_Body_Base)
|
||||
@@ -346,6 +344,110 @@ async def get_event_obj(
|
||||
# ### END ### API Event ### get_event_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event ### get_account_obj_event_list() ###
|
||||
# Updated 2021-09-28
|
||||
@router.get('/account/{account_id}/event/list', response_model=Resp_Body_Base)
|
||||
async def get_account_obj_event_list(
|
||||
account_id: str = Query(..., min_length=1, max_length=22),
|
||||
limit: int = 500, # For now this covers any included objects or object lists
|
||||
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
||||
conference: bool = False, # Events with badges, sessions, presentations, presenters, registration, etc
|
||||
# inc_account_cfg: bool = False,
|
||||
inc_address: bool = False, # Under event and under contact
|
||||
# inc_address_location: bool = False,
|
||||
inc_contact: bool = False,
|
||||
# inc_event_abstract_list: bool = False,
|
||||
# inc_event_badge_list: bool = False,
|
||||
inc_event_cfg: bool = False,
|
||||
# inc_event_device_list: bool = False,
|
||||
# inc_event_exhibit_list: bool = False,
|
||||
inc_event_file_list: bool = False,
|
||||
# inc_event_location: bool = False,
|
||||
inc_event_location_list: bool = False,
|
||||
# inc_event_person: bool = False,
|
||||
inc_event_person_list: bool = False,
|
||||
inc_event_presentation_list: bool = False,
|
||||
# inc_event_presenter_cat: bool = False,
|
||||
inc_event_presenter_list: bool = False,
|
||||
# inc_event_registration_cfg: bool = False,
|
||||
# inc_event_registration_list: bool = False,
|
||||
inc_event_session_list: bool = False,
|
||||
# inc_event_track: bool = False,
|
||||
# inc_event_track_list: bool = False,
|
||||
# inc_order_list: bool = False,
|
||||
inc_organization: bool = False,
|
||||
inc_person: bool = False,
|
||||
inc_poc_event_person: bool = False,
|
||||
inc_product: bool = False,
|
||||
inc_product_list: bool = False,
|
||||
inc_user: bool = False,
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else: return mk_resp(data=None, status_code=404)
|
||||
|
||||
response_data = None
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
|
||||
# Updated 2021-09-28
|
||||
if event_rec_list_result := get_event_rec_list(
|
||||
account_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
conference = conference,
|
||||
):
|
||||
event_result_list = []
|
||||
for event_rec in event_rec_list_result:
|
||||
if load_event_result := load_event_obj(
|
||||
event_id = event_rec.get('event_id', None),
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
# model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
# inc_event_abstract_list = inc_event_abstract_list,
|
||||
# inc_event_badge_list = inc_event_badge_list,
|
||||
inc_event_cfg = inc_event_cfg,
|
||||
# inc_event_device_list = inc_event_device_list,
|
||||
# inc_event_exhibit_list = inc_event_exhibit_list,
|
||||
inc_event_file_list = inc_event_file_list,
|
||||
# inc_event_location = inc_event_location,
|
||||
inc_event_location_list = inc_event_location_list,
|
||||
# inc_event_person = inc_event_person,
|
||||
inc_event_person_list = inc_event_person_list,
|
||||
inc_event_presentation_list = inc_event_presentation_list,
|
||||
# inc_event_presenter_cat = inc_event_presenter_cat,
|
||||
inc_event_presenter_list = inc_event_presenter_list,
|
||||
# inc_event_registration_cfg = inc_event_registration_cfg,
|
||||
# inc_event_registration_list = inc_event_registration_list,
|
||||
inc_event_session_list = inc_event_session_list,
|
||||
# inc_event_track = inc_event_track,
|
||||
# inc_event_track_list = inc_event_track_list,
|
||||
# inc_order_list = inc_order_list,
|
||||
inc_organization = inc_organization,
|
||||
inc_person = inc_person,
|
||||
# inc_product = inc_product,
|
||||
# inc_product_list = inc_product_list,
|
||||
inc_user = inc_user,
|
||||
):
|
||||
event_result_list.append(load_event_result)
|
||||
else:
|
||||
event_result_list.append(None)
|
||||
response_data = event_result_list
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
# ### END ### API Event ### get_account_obj_event_list() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Methods ### get_person_event_obj_li() ###
|
||||
# Updated 2021-07-12
|
||||
|
||||
Reference in New Issue
Block a user