Working on lookups
This commit is contained in:
@@ -18,7 +18,7 @@ from .lib_general import *
|
||||
from .log import *
|
||||
|
||||
# Import the routers here first:
|
||||
from .routers import api_crud, api, account, address, archive, archive_content, contact, event, event_exhibit, event_registration, event_session, flask_cfg, membership, order, order_cart, organization, page, person, post, post_comment, product, site, site_domain, user, user_person, websockets # , items, journals
|
||||
from .routers import api_crud, api, account, address, archive, archive_content, contact, event, event_exhibit, event_registration, event_session, flask_cfg, lookup, membership, order, order_cart, organization, page, person, post, post_comment, product, site, site_domain, user, user_person, websockets # , items, journals
|
||||
|
||||
from .db_sql import db
|
||||
|
||||
@@ -142,6 +142,11 @@ app.include_router(
|
||||
#dependencies=[Depends(get_account_header)],
|
||||
#responses={404: {'description': 'Not found'}},
|
||||
)
|
||||
app.include_router(
|
||||
lookup.router,
|
||||
prefix='/lu',
|
||||
tags=['Lookup'],
|
||||
)
|
||||
app.include_router(
|
||||
membership.router,
|
||||
prefix='/membership',
|
||||
@@ -260,7 +265,9 @@ origins = [
|
||||
'http://localhost:5000',
|
||||
'http://fastapi.localhost:5000',
|
||||
'http://demo.localhost:5000',
|
||||
'http://localhost:7800',
|
||||
'https://oneskyit.com',
|
||||
'http://dev-idaa.localhost:5000'
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
|
||||
48
app/routers/lookup.py
Normal file
48
app/routers/lookup.py
Normal file
@@ -0,0 +1,48 @@
|
||||
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
|
||||
|
||||
from ..lib_general import *
|
||||
from app.config import settings
|
||||
from app.db_sql import *
|
||||
|
||||
from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
|
||||
|
||||
from ..models.response_model import *
|
||||
#from ..models.lookup_model import Lookup_Base
|
||||
|
||||
|
||||
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,
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
print('HERE')
|
||||
|
||||
allowed_lookup_tables = ['country', 'country_subdivision', 'event_session_type', 'file_purpose', 'membership_status', 'order_status', 'user_status']
|
||||
|
||||
if for_lookup_name in allowed_lookup_tables:
|
||||
table_name = f'lu_{for_lookup_name}'
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400)
|
||||
|
||||
sql_result = sql_select(table_name=table_name)
|
||||
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(sql_result)
|
||||
|
||||
return mk_resp(data=sql_result)
|
||||
@@ -46,12 +46,12 @@ async def post_membership_obj(
|
||||
async def patch_membership_obj(
|
||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
||||
obj: Membership_Base = None,
|
||||
x_account_id: Optional[str] = Header(..., ),
|
||||
#x_account_id: Optional[str] = Header(..., ),
|
||||
return_obj: Optional[bool] = True,
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
obj_type = 'membership'
|
||||
|
||||
Reference in New Issue
Block a user