Working on various... order, post, cart, etc
This commit is contained in:
@@ -14,6 +14,7 @@ from app.methods.account_cfg_methods import load_account_cfg_obj
|
||||
from app.methods.membership_group_methods import get_membership_group_rec_list, load_membership_group_obj
|
||||
from app.methods.membership_member_methods import get_membership_member_rec_list, load_membership_member_obj
|
||||
from app.methods.membership_type_methods import get_membership_type_rec_list, load_membership_type_obj
|
||||
from app.methods.post_methods import get_post_rec_list, load_post_obj
|
||||
|
||||
from app.models.account_models import Account_Base
|
||||
from app.models.response_models import Resp_Body_Base, mk_resp
|
||||
@@ -508,6 +509,67 @@ async def get_account_obj_membership_type_list(
|
||||
# ### END ### API Account ### get_account_obj_membership_type_list() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Account ### get_account_obj_post_list() ###
|
||||
# Working well as of 2021-06-28. Using as a template for other routes.
|
||||
@router.get('/{account_id}/post_list', response_model=Resp_Body_Base)
|
||||
async def get_account_obj_post_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
|
||||
archive_on: datetime.datetime = None,
|
||||
inc_account_cfg: bool = False,
|
||||
inc_address: bool = False, # Under contact
|
||||
inc_contact: bool = False,
|
||||
inc_person: bool = False,
|
||||
inc_post_comment_list: bool = False,
|
||||
inc_user: bool = False,
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
):
|
||||
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
|
||||
|
||||
# Updated 2021-06-28
|
||||
if post_rec_list_result := get_post_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
archive_on = archive_on
|
||||
):
|
||||
post_result_list = []
|
||||
for post_rec in post_rec_list_result:
|
||||
if load_post_result := load_post_obj(
|
||||
post_id = post_rec.get('post_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_person = inc_person,
|
||||
inc_post_comment_list = inc_post_comment_list,
|
||||
inc_user = inc_user,
|
||||
):
|
||||
post_result_list.append(load_post_result)
|
||||
else:
|
||||
post_result_list.append(None)
|
||||
response_data = post_result_list
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
# ### END ### API Account ### get_account_obj_post_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),
|
||||
|
||||
Reference in New Issue
Block a user