Work on API keys and tokens clean up and person list
This commit is contained in:
@@ -279,7 +279,7 @@ async def get_account_obj_new(
|
|||||||
|
|
||||||
# ### BEGIN ### API Account ### get_account_obj_event_list() ###
|
# ### BEGIN ### API Account ### get_account_obj_event_list() ###
|
||||||
# Working well as of 2021-06-30. Using as a template for other routes.
|
# 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)
|
@router.get('/{account_id}/event/list', response_model=Resp_Body_Base)
|
||||||
async def get_account_obj_event_list(
|
async def get_account_obj_event_list(
|
||||||
account_id: str = Query(..., min_length=1, max_length=22),
|
account_id: str = Query(..., min_length=1, max_length=22),
|
||||||
limit: int = 500, # For now this covers any included objects or object lists
|
limit: int = 500, # For now this covers any included objects or object lists
|
||||||
|
|||||||
@@ -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.routers.api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
|
||||||
|
|
||||||
from app.methods.membership_person_methods import get_membership_person_rec_list, load_membership_person_obj
|
# from app.methods.membership_person_methods import load_membership_person_obj
|
||||||
from app.methods.order_methods import get_order_rec_list, load_order_obj
|
from app.methods.order_methods import get_order_rec_list, load_order_obj
|
||||||
from app.methods.person_methods import create_update_person_obj, load_person_obj, update_person_obj
|
from app.methods.person_methods import create_update_person_obj, get_person_rec_list, load_person_obj, update_person_obj
|
||||||
|
|
||||||
from app.models.person_models import Person_Base
|
from app.models.person_models import Person_Base
|
||||||
from app.models.response_models import Resp_Body_Base, mk_resp
|
from app.models.response_models import Resp_Body_Base, mk_resp
|
||||||
@@ -315,6 +315,71 @@ async def get_person_obj_order_list(
|
|||||||
# ### END ### API Person ### get_person_obj_order_list() ###
|
# ### END ### API Person ### get_person_obj_order_list() ###
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ### BEGIN ### API Person ### get_account_obj_person_list() ###
|
||||||
|
# Working well as of 2021-07-09. Using as a template for other routes.
|
||||||
|
@router.get('/account/{account_id}/person/list', response_model=Resp_Body_Base)
|
||||||
|
async def get_account_obj_person_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
|
||||||
|
inc_address: bool = False,
|
||||||
|
inc_contact: bool = False,
|
||||||
|
# inc_membership_group_list: bool = False, # The list of all membership groups a person is a part of
|
||||||
|
inc_membership_person: bool = False,
|
||||||
|
# inc_membership_person_profile: bool = False, # Profile?
|
||||||
|
# inc_membership_person_profile_cust: bool = False, # Extended profile?
|
||||||
|
# inc_membership_type_person: bool = False,
|
||||||
|
# inc_order: bool = False,
|
||||||
|
# inc_organization: bool = False,
|
||||||
|
# inc_product: bool = False, # The product the person actually purchased for a member_type or member_group
|
||||||
|
# inc_product_list: bool = False, # The list of products that give access to a member_type or member_group
|
||||||
|
inc_user: bool = False,
|
||||||
|
x_account_id: str = Header(...),
|
||||||
|
by_alias: Optional[bool] = True,
|
||||||
|
exclude_unset: Optional[bool] = True,
|
||||||
|
):
|
||||||
|
log.setLevel(logging.DEBUG) # 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 person_rec_list_result := get_person_rec_list(
|
||||||
|
for_obj_type = 'account',
|
||||||
|
for_obj_id = account_id,
|
||||||
|
limit = limit,
|
||||||
|
enabled = enabled,
|
||||||
|
):
|
||||||
|
person_result_list = []
|
||||||
|
for person_rec in person_rec_list_result:
|
||||||
|
if load_person_result := load_person_obj(
|
||||||
|
person_id = person_rec.get('person_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_membership_person = inc_membership_person,
|
||||||
|
inc_user = inc_user,
|
||||||
|
):
|
||||||
|
person_result_list.append(load_person_result)
|
||||||
|
else:
|
||||||
|
person_result_list.append(None)
|
||||||
|
response_data = person_result_list
|
||||||
|
else:
|
||||||
|
return mk_resp(data=False, status_code=400) # Bad Request
|
||||||
|
|
||||||
|
return mk_resp(data=response_data)
|
||||||
|
# ### END ### API Person ### get_account_obj_person_list() ###
|
||||||
|
|
||||||
|
|
||||||
@router.delete('/person/{obj_id}', response_model=Resp_Body_Base)
|
@router.delete('/person/{obj_id}', response_model=Resp_Body_Base)
|
||||||
async def delete_person_obj(
|
async def delete_person_obj(
|
||||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
obj_id: str = Query(..., min_length=1, max_length=22),
|
||||||
|
|||||||
Reference in New Issue
Block a user