Updated get user object
This commit is contained in:
@@ -44,7 +44,7 @@ def load_user_obj(user_id:int|str, inc_roles:bool=False, inc_contact:bool=False,
|
|||||||
if inc_person:
|
if inc_person:
|
||||||
if person_rec := sql_select(table_name='v_person', field_name='person_id', field_value=user_rec.get('person_id', None)):
|
if person_rec := sql_select(table_name='v_person', field_name='person_id', field_value=user_rec.get('person_id', None)):
|
||||||
user_rec['person'] = person_rec
|
user_rec['person'] = person_rec
|
||||||
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
log.debug(person_rec)
|
log.debug(person_rec)
|
||||||
|
|
||||||
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
|
|||||||
@@ -285,3 +285,4 @@ class User_Base(BaseModel):
|
|||||||
fields = base_fields
|
fields = base_fields
|
||||||
|
|
||||||
#User_Base.update_forward_refs()
|
#User_Base.update_forward_refs()
|
||||||
|
#User_Out_Base.update_forward_refs()
|
||||||
|
|||||||
@@ -559,10 +559,11 @@ async def lookup_username(
|
|||||||
return mk_resp(data=data)
|
return mk_resp(data=data)
|
||||||
|
|
||||||
|
|
||||||
@router.get('/{obj_id}', response_model=Resp_Body_Base)
|
@router.get('/{user_id}', response_model=Resp_Body_Base)
|
||||||
async def get_user_obj(
|
async def get_user_obj(
|
||||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
user_id: str = Query(..., min_length=1, max_length=22),
|
||||||
x_account_id: str = Header(...),
|
x_account_id: str = Header(...),
|
||||||
|
inc_roles: bool = False,
|
||||||
inc_contact: bool = False,
|
inc_contact: bool = False,
|
||||||
inc_organization: bool = False,
|
inc_organization: bool = False,
|
||||||
inc_person: bool = False,
|
inc_person: bool = False,
|
||||||
@@ -572,14 +573,15 @@ async def get_user_obj(
|
|||||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
log.debug(locals())
|
log.debug(locals())
|
||||||
|
|
||||||
obj_type = 'user'
|
user_obj = load_user_obj(
|
||||||
result = get_obj_template(
|
user_id=user_id,
|
||||||
obj_type=obj_type,
|
inc_roles=inc_roles,
|
||||||
obj_id=obj_id,
|
inc_contact=inc_contact,
|
||||||
by_alias=True,
|
inc_organization=inc_organization,
|
||||||
exclude_unset=True,
|
inc_person=inc_person
|
||||||
)
|
).dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||||
return result
|
data = user_obj
|
||||||
|
return mk_resp(data=data)
|
||||||
|
|
||||||
|
|
||||||
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
||||||
|
|||||||
Reference in New Issue
Block a user