Added person lookup by email and other minor changes.
This commit is contained in:
@@ -839,7 +839,7 @@ async def ins_up_membership_person_data(
|
||||
|
||||
if membership_type_name := record.get('membership_type', None): pass
|
||||
else:
|
||||
log.warning(f'No membership information information found. Person ID: {person_id}, External ID: {external_id}, Email: {email}')
|
||||
log.warning(f'No membership information. Person ID: {person_id}, External ID: {external_id}, Email: {email}')
|
||||
continue
|
||||
|
||||
data = {}
|
||||
|
||||
@@ -372,6 +372,69 @@ async def person_obj_external_id(
|
||||
# ### END ### API Person ### person_obj_external_id() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Person ### lookup_email() ###
|
||||
# Updated 2021-12-01
|
||||
@router.get('/person/lookup_email', response_model=Resp_Body_Base)
|
||||
async def lookup_email(
|
||||
email: str = Query(..., min_length=5, max_length=75),
|
||||
inc_address: bool = False,
|
||||
inc_contact: bool = False,
|
||||
inc_user: bool = False,
|
||||
inc_user_role_list: bool = False,
|
||||
enabled: str = 'enabled',
|
||||
limit: int = 50,
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
x_account_id: str = Header(...),
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=x_account_id, table_name='account'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=response)
|
||||
|
||||
import time
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
if person_rec_list_result := get_person_rec_list(
|
||||
#account_id = account_id,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
email = email,
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
):
|
||||
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),
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
inc_user = inc_user,
|
||||
inc_user_role_list = inc_user_role_list,
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
# model_as_dict = model_as_dict,
|
||||
):
|
||||
person_result_list.append(load_person_result)
|
||||
else:
|
||||
person_result_list.append(None)
|
||||
response_data = person_result_list
|
||||
elif person_rec_list_result is 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
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
# ### END ### API Person ### lookup_email() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Person ### get_person_obj() ###
|
||||
# Working well as of 2021-06-25. Using as a template for other routes.
|
||||
@router.get('/person/{person_id}', response_model=Resp_Body_Base)
|
||||
|
||||
Reference in New Issue
Block a user