Working on all module routes, methods, and models
This commit is contained in:
@@ -181,8 +181,8 @@ async def lookup_membership_type_obj(
|
||||
|
||||
# ### BEGIN ### API Membership Type ### get_membership_type_obj() ###
|
||||
# Working well as of 2021-06-21. Using as a template for other routes.
|
||||
@router.get('/{membership_type_id}', response_model=Resp_Body_Base)
|
||||
async def get_membership_type_obj(
|
||||
@router.get('/{membership_type_id}/v5', response_model=Resp_Body_Base)
|
||||
async def get_membership_type_obj_v5(
|
||||
membership_type_id: str = Query(..., min_length=1, max_length=22),
|
||||
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
||||
limit: int = 500, # For now this covers any included objects or object lists
|
||||
|
||||
@@ -129,27 +129,74 @@ async def get_person_obj_li(
|
||||
return result
|
||||
|
||||
|
||||
@router.get('/{person_id}', response_model=Resp_Body_Base)
|
||||
async def get_person_obj(
|
||||
|
||||
# ### BEGIN ### API Person ### get_person_obj_v5() ###
|
||||
# Working well as of 2021-06-11. Using as a template for other routes.
|
||||
@router.get('/{person_id}/v5', response_model=Resp_Body_Base)
|
||||
async def get_person_obj_v5(
|
||||
person_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
|
||||
inc_address: bool = False, # Priority l1
|
||||
# inc_archive_list: bool = False, # Priority l3
|
||||
inc_contact: bool = False, # Priority l1
|
||||
inc_event_list: bool = False, # Priority l1
|
||||
# inc_hosted_file_list: bool = False, # Priority l3
|
||||
inc_journal_list: bool = False, # Priority l2
|
||||
# inc_journal_entry_list: bool = False, # Priority l3
|
||||
inc_membership_member: bool = False, # Priority l2
|
||||
# inc_membership_list: bool = False, # ???
|
||||
inc_order_line_list: bool = False, # Priority l1
|
||||
inc_order_list: bool = False, # Priority l1
|
||||
inc_order_cart_list: bool = False, # Priority l1
|
||||
inc_organization: bool = False, # Priority l1
|
||||
# inc_organization_list: bool = False,
|
||||
inc_post_list: bool = False, # Priority l2
|
||||
inc_post_comment_list: bool = False, # Priority l3
|
||||
inc_user: bool = False, # Priority l1
|
||||
x_account_id: str = Header(...),
|
||||
inc_address: bool = False,
|
||||
inc_contact: bool = False,
|
||||
inc_organization: bool = False,
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
person_obj = load_person_obj(
|
||||
person_id=person_id,
|
||||
inc_contact=inc_contact,
|
||||
inc_address=inc_address,
|
||||
inc_organization=inc_organization,
|
||||
).dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
data = person_obj
|
||||
return mk_resp(data=person_obj)
|
||||
if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass
|
||||
else:
|
||||
return mk_resp(data=None, status_code=404)
|
||||
|
||||
if person_dict := load_person_obj(
|
||||
person_id = person_id,
|
||||
limit = limit,
|
||||
model_as_dict = True, # NOTE: returning model as a dict
|
||||
enabled = enabled,
|
||||
inc_address = inc_address,
|
||||
# inc_archive_list = inc_archive_list,
|
||||
inc_contact = inc_contact,
|
||||
inc_event_list = inc_event_list,
|
||||
# inc_hosted_file_list = inc_hosted_file_list,
|
||||
inc_journal_list = inc_journal_list,
|
||||
# inc_journal_entry_list = inc_journal_entry_list,
|
||||
inc_membership_member = inc_membership_member,
|
||||
# inc_membership_list = inc_membership_list, # ???
|
||||
inc_order_line_list = inc_order_line_list,
|
||||
inc_order_list = inc_order_list,
|
||||
inc_order_cart_list = inc_order_cart_list,
|
||||
inc_organization = inc_organization,
|
||||
# inc_organization_list = inc_organization_list,
|
||||
inc_post_list = inc_post_list,
|
||||
inc_post_comment_list = inc_post_comment_list,
|
||||
inc_user = inc_user,
|
||||
):
|
||||
if isinstance(person_dict, dict):
|
||||
response_data = person_dict
|
||||
else:
|
||||
response_data = person_dict
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
# ### END ### API Person ### get_person_obj_v5() ###
|
||||
|
||||
|
||||
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
||||
|
||||
@@ -559,10 +559,10 @@ async def lookup_username(
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API User ### get_user_obj_new() ###
|
||||
# ### BEGIN ### API User ### get_user_obj_v5() ###
|
||||
# Working well as of 2021-06-11. Using as a template for other routes.
|
||||
@router.get('/{user_id}/json', response_model=Resp_Body_Base)
|
||||
async def get_user_obj_new(
|
||||
@router.get('/{user_id}/v5', response_model=Resp_Body_Base)
|
||||
async def get_user_obj_v5(
|
||||
user_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
|
||||
@@ -573,8 +573,9 @@ async def get_user_obj_new(
|
||||
# inc_hosted_file_list: bool = False, # Priority l3
|
||||
inc_journal_list: bool = False, # Priority l2
|
||||
# inc_journal_entry_list: bool = False, # Priority l3
|
||||
inc_membership: bool = False, # Priority l2
|
||||
inc_membership_member: bool = False, # Priority l2
|
||||
# inc_membership_list: bool = False, # ???
|
||||
inc_order_line_list: bool = False, # Priority l1
|
||||
inc_order_list: bool = False, # Priority l1
|
||||
inc_order_cart_list: bool = False, # Priority l1
|
||||
inc_organization: bool = False, # Priority l1
|
||||
@@ -582,7 +583,7 @@ async def get_user_obj_new(
|
||||
inc_person: bool = False, # Priority l1
|
||||
# inc_person_list: bool = False,
|
||||
inc_post_list: bool = False, # Priority l2
|
||||
# inc_post_comment_list: bool = False, # Priority l3
|
||||
inc_post_comment_list: bool = False, # Priority l3
|
||||
inc_user_role_list: bool = False, # Priority l1
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
@@ -607,8 +608,9 @@ async def get_user_obj_new(
|
||||
# inc_hosted_file_list = inc_hosted_file_list,
|
||||
inc_journal_list = inc_journal_list,
|
||||
# inc_journal_entry_list = inc_journal_entry_list,
|
||||
inc_membership = inc_membership,
|
||||
inc_membership_member = inc_membership_member,
|
||||
# inc_membership_list = inc_membership_list, # ???
|
||||
inc_order_line_list = inc_order_line_list,
|
||||
inc_order_list = inc_order_list,
|
||||
inc_order_cart_list = inc_order_cart_list,
|
||||
inc_organization = inc_organization,
|
||||
@@ -627,8 +629,7 @@ async def get_user_obj_new(
|
||||
return mk_resp(data=False, status_code=400) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
# ### END ### API User ### get_user_obj_new() ###
|
||||
|
||||
# ### END ### API User ### get_user_obj_v5() ###
|
||||
|
||||
|
||||
@router.get('/{user_id}', response_model=Resp_Body_Base)
|
||||
|
||||
Reference in New Issue
Block a user