Clean up and I think I fixed a weird bug with Pydantic models and the list object type. It seems to try for a dict conversion first if Union[dict,list] is used.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import datetime
|
||||
#from datetime import datetime, time, timedelta
|
||||
from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
@@ -12,7 +11,7 @@ from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_
|
||||
|
||||
from app.methods.lu_post_topic_methods import get_lu_post_topic_rec_list
|
||||
|
||||
from app.models.response_models import *
|
||||
from app.models.response_models import Resp_Body_Base, mk_resp
|
||||
#from app.models.lookup_models import Lookup_Base
|
||||
|
||||
|
||||
@@ -31,7 +30,7 @@ async def get_lookup_li(
|
||||
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', 'post_topic', 'user_status']
|
||||
allowed_lookup_tables = ['country', 'country_subdivision', 'event_session_type', 'file_purpose', 'membership_member_status', 'order_status', 'post_topic', 'time_zone', 'user_status']
|
||||
|
||||
if for_lookup_name in allowed_lookup_tables: pass
|
||||
else:
|
||||
@@ -48,12 +47,46 @@ async def get_lookup_li(
|
||||
response_data = lu_post_topic_rec_list_result
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400) # Bad Request
|
||||
elif for_lookup_name == 'time_zone':
|
||||
table_name = f'v_lu_{for_lookup_name}'
|
||||
lu_time_zone_result = sql_select(table_name=table_name)
|
||||
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(lu_time_zone_result)
|
||||
log.debug(type(lu_time_zone_result))
|
||||
lu_time_zone_result = lu_time_zone_result[0:10]
|
||||
# fake_li = []
|
||||
# import secrets
|
||||
# for time_zone in lu_time_zone_result:
|
||||
# fake = {}
|
||||
# # fake['id'] = time_zone['id']
|
||||
# # fake['name'] = time_zone['name']
|
||||
# fake['xxx'] = secrets.token_urlsafe(8)
|
||||
# fake['yyy'] = secrets.token_urlsafe(8)
|
||||
# fake_li.append(fake)
|
||||
# # time_zone['name'] = 'asdf'
|
||||
response_data = lu_time_zone_result
|
||||
# response_data = fake_li
|
||||
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(lu_list_result)
|
||||
response_data = lu_list_result
|
||||
|
||||
# fake_li = []
|
||||
# import secrets
|
||||
# for list_item in lu_list_result:
|
||||
# fake = {}
|
||||
# # fake['id'] = time_zone['id']
|
||||
# # fake['name'] = time_zone['name']
|
||||
# fake['xxx'] = secrets.token_urlsafe(8)
|
||||
# fake['yyy'] = secrets.token_urlsafe(8)
|
||||
# fake_li.append(fake)
|
||||
# response_data = fake_li
|
||||
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(response_data)
|
||||
response_data = response_data
|
||||
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(response_data)
|
||||
return mk_resp(data=response_data)
|
||||
|
||||
@@ -408,7 +408,7 @@ async def lookup_user_obj(
|
||||
return mk_resp(data=data)
|
||||
|
||||
|
||||
# Look up a user with an email addresss for an account
|
||||
# Look up a user with an email address for an account
|
||||
@router.get('/lookup_email', response_model=Resp_Body_Base)
|
||||
async def lookup_email(
|
||||
account_id: Union[int,str],
|
||||
|
||||
Reference in New Issue
Block a user