Working on various... order, post, cart, etc
This commit is contained in:
@@ -10,6 +10,8 @@ from app.db_sql import sql_select, redis_lookup_id_random
|
||||
|
||||
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.lu_post_topic_methods import get_lu_post_topic_rec_list
|
||||
|
||||
from app.models.response_models import *
|
||||
#from app.models.lookup_models import Lookup_Base
|
||||
|
||||
@@ -20,27 +22,38 @@ router = APIRouter()
|
||||
@router.get('/{for_lookup_name}/list', response_model=Resp_Body_Base)
|
||||
async def get_lookup_li(
|
||||
for_lookup_name: Optional[str] = Query(None, min_length=2, max_length=50),
|
||||
#for_lookup_id: Optional[str] = Query(None, min_length=1, max_length=22),
|
||||
#x_account_id: str = Header(...),
|
||||
#by_alias: Optional[bool] = True,
|
||||
#include: Optional[list] = [],
|
||||
#exclude: Optional[list] = [],
|
||||
#exclude_unset: Optional[bool] = True,
|
||||
#exclude_none: Optional[bool] = True,
|
||||
account_id: Optional[str] = Query(None, min_length=2, max_length=50),
|
||||
for_type: Optional[str] = Query(None, min_length=2, max_length=50),
|
||||
inc_admin_options: bool = False,
|
||||
limit: int = 1000,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
allowed_lookup_tables = ['country', 'country_subdivision', 'event_session_type', 'file_purpose', 'membership_member_status', 'order_status', 'user_status']
|
||||
allowed_lookup_tables = ['country', 'country_subdivision', 'event_session_type', 'file_purpose', 'membership_member_status', 'order_status', 'post_topic', 'user_status']
|
||||
|
||||
if for_lookup_name in allowed_lookup_tables:
|
||||
table_name = f'lu_{for_lookup_name}'
|
||||
if for_lookup_name in allowed_lookup_tables: pass
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400)
|
||||
|
||||
sql_result = sql_select(table_name=table_name)
|
||||
if for_lookup_name == 'post_topic':
|
||||
if lu_post_topic_rec_list_result := get_lu_post_topic_rec_list(
|
||||
account_id = account_id,
|
||||
for_type = for_type,
|
||||
inc_admin_options = inc_admin_options,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
response_data = lu_post_topic_rec_list_result
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400) # Bad Request
|
||||
else:
|
||||
table_name = f'lu_{for_lookup_name}'
|
||||
lu_list_result = sql_select(table_name=table_name)
|
||||
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(sql_result)
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(lu_list_result)
|
||||
response_data = lu_list_result
|
||||
|
||||
return mk_resp(data=sql_result)
|
||||
return mk_resp(data=response_data)
|
||||
|
||||
Reference in New Issue
Block a user