This commit is contained in:
Scott Idem
2021-12-29 19:42:27 -05:00
parent e99be8070e
commit 0866fbbed6
18 changed files with 78 additions and 50 deletions

View File

@@ -18,6 +18,11 @@ engine = create_engine(url=connection_string, pool_size=25, pool_recycle=60, poo
db = engine.connect()
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.debug(db)
# log.debug(vars(db))
# log.debug(dir(db))
# #### ### ## # BEGIN SQL # ## ### ####
# Create, Read/Get, Update, Delete

View File

@@ -14,8 +14,8 @@ from sqlalchemy import create_engine, text
from sqlalchemy.exc import IntegrityError, OperationalError
from . import config
from app.lib_general import log, logging
from app.log import log
# from app.lib_general import log, logging
from app.log import log, logging
# Import the routers here first:
from app.routers import api_crud, api, importing, account, activity_log, address, archive, archive_content, contact, cont_edu_cert, cont_edu_cert_person, event, event_badge, event_badge_template, event_exhibit, event_file, event_importing, event_location, event_person, event_person_detail, event_person_tracking, event_presentation, event_presenter, event_registration, event_session, flask_cfg, hosted_file, journal, journal_entry, log_client_viewing, lookup, membership_cfg, membership_group, membership_group_person, membership_person, membership_person_profile, membership_type, membership_type_person, order, order_line, order_cart, organization, page, person, person_user, post, post_comment, product, site, site_domain, user, websockets#, e_impexium
@@ -23,7 +23,7 @@ from app.routers import api_crud, api, importing, account, activity_log, address
from app.db_sql import db
print('### **** *** ** * The Aether FastAPI API app is loading... * ** *** **** ###')
print('### **** *** ** * The Aether FastAPI API is loading... * ** *** **** ###')
#log = logging.getLogger('root')
@@ -325,28 +325,38 @@ origins = [
'https://oneskyit.com',
'http://192.168.32.20:3000',
'http://192.168.32.20:8080',
'http://fastapi.localhost',
'http://localhost',
'http://localhost:3000',
'http://localhost:5000',
'http://localhost:8080',
'http://localhost:7800',
'http://app-local.oneskyit.com',
'http://cmsc.home:5000',
'http://cmsc.localhost:5000',
'http://connect.home:5000',
'http://connect.localhost:5000',
'http://demo.home:5000',
'http://demo.localhost:5000',
'http://dev-idaa.home:5000',
'http://dev-idaa.localhost:5000',
'http://dev.home:5000',
'http://fastapi.localhost:5000',
'http://idaa.home:5000',
'http://idaa.localhost:5000',
'http://ishlt.home:5000',
'http://ishlt.localhost:5000',
'http://svelte.localhost:5555',
'http://fastapi.localhost',
'http://api.oneskyit.local:5000',
'http://app.oneskyit.local:5000',
'http://fastapi.oneskyit.local:5000',
'http://svelte.oneskyit.local:5555',
'http://connect.oneskyit.local:5000',
'http://connect.oneskyit.local:5000',
'http://demo.oneskyit.local:5000',
'http://demo.oneskyit.local:5000',
'http://dev.oneskyit.local:5000',
'http://dev-app.oneskyit.local:5000',
'http://dev-svelte.oneskyit.local:5555',
'http://dev-cmsc.oneskyit.local:5000',
'http://dev-idaa.oneskyit.local:5000',
'http://dev-idaa.oneskyit.local:5000',
'http://dev-ishlt.oneskyit.local:5000',
'http://cmsc.oneskyit.local:5000',
'http://idaa.oneskyit.local:5000',
'http://ishlt.oneskyit.local:5000',
]
app.add_middleware(
@@ -367,7 +377,7 @@ async def startup():
log.setLevel(logging.INFO) # DEBUG, INFO, WARN, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
log.info('The Aether FastAPI API app is starting up...')
log.info('The Aether FastAPI API is starting up...')
#await database.connect()
@@ -376,7 +386,7 @@ async def shutdown():
log.setLevel(logging.INFO) # DEBUG, INFO, WARN, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
log.info('The Aether FastAPI API app is shutting down...')
log.info('The Aether FastAPI API is shutting down...')
#await database.disconnect()

View File

@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "../.."
}
],
"settings": {}
}

View File

@@ -12,7 +12,7 @@ from app.models.common_field_schema import base_fields, default_num_bytes
class Address_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -12,7 +12,7 @@ from app.models.product_models import Product_Base
class Cont_Edu_Cert_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -14,7 +14,7 @@ from app.models.user_models import User_Base
class Cont_Edu_Cert_Person_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -13,7 +13,7 @@ from app.models.address_models import Address_Base
class Contact_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -12,7 +12,7 @@ from app.models.hosted_file_models import Hosted_File_Base
class Event_File_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -190,7 +190,7 @@ class Event_Person_Profile_Base(BaseModel):
class Event_Person_Profile_Base_Up(Event_Person_Profile_Base):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())

View File

@@ -12,7 +12,7 @@ from app.models.event_registration_cfg_models import Event_Registration_Cfg_Base
class Event_Registration_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -11,7 +11,7 @@ from app.models.common_field_schema import base_fields, default_num_bytes
class Log_Client_Viewing_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -20,7 +20,7 @@ from app.models.product_models import Product_Base
class Membership_Person_Base(BaseModel):
log.setLevel(logging.DEBUG)
log.setLevel(logging.INFO)
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -14,7 +14,7 @@ from app.models.organization_models import Organization_Base
class Membership_Person_Profile_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(
@@ -135,7 +135,7 @@ class Membership_Person_Profile_Base(BaseModel):
class Membership_Person_Profile_Base_Up(Membership_Person_Profile_Base):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())

View File

@@ -17,7 +17,7 @@ from app.models.organization_models import Organization_Base
# ### BEGIN ### API Person Models ### Person_Base() ###
class Person_Base(BaseModel):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -33,6 +33,7 @@ class Site_Domain_Base(BaseModel):
required_referrer: Optional[str]
valid_for: Optional[int] # number of hours
enable: Optional[bool]
created_on: Optional[datetime.datetime] = None
updated_on: Optional[datetime.datetime] = None

View File

@@ -76,7 +76,7 @@ async def patch_site_domain_obj(
@router.get('/lookup_fqdn', response_model=Resp_Body_Base)
async def lookup_site_domain_obj(
fqdn: str,
access_key: Optional[str] = None,
access_key: Optional[str] = Query(None, min_length=4, max_length=50),
referrer: Optional[str] = None,
x_account_id: str = Header(...),
by_alias: bool = True,
@@ -84,7 +84,7 @@ async def lookup_site_domain_obj(
exclude_none: bool = True,
response: Response = Response,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
data = {}
@@ -115,21 +115,25 @@ async def lookup_site_domain_obj(
# NOTE: This need to broken out into a methods function for site and or site_domain
if site_domain_obj_result := sql_select(data=data, sql=sql):
try:
site_obj = Site_Base(**site_domain_obj_result).dict(by_alias=by_alias, exclude_unset=exclude_unset, exclude_none=exclude_none)
log.debug(site_obj)
except ValidationError as e:
log.error(e.json())
try:
site_domain_obj = Site_Domain_Base(**site_domain_obj_result).dict(by_alias=by_alias, exclude_unset=exclude_unset, exclude_none=exclude_none)
if isinstance(site_domain_obj_result, dict):
try:
site_obj = Site_Base(**site_domain_obj_result).dict(by_alias=by_alias, exclude_unset=exclude_unset, exclude_none=exclude_none)
log.debug(site_obj)
except ValidationError as e:
log.error(e.json())
try:
site_domain_obj = Site_Domain_Base(**site_domain_obj_result).dict(by_alias=by_alias, exclude_unset=exclude_unset, exclude_none=exclude_none)
log.debug(site_domain_obj)
except ValidationError as e:
log.error(e.json())
site_domain_obj['site'] = site_obj
log.debug(site_domain_obj)
except ValidationError as e:
log.error(e.json())
site_domain_obj['site'] = site_obj
log.debug(site_domain_obj)
return mk_resp(data=site_domain_obj)
return mk_resp(data=site_domain_obj, response=response)
else:
log.error(f'More than one site domain records were returned. This was unexpected and needs to be corrected. FQDN: {fqdn}')
return mk_resp(data=False, status_code=500, status_message='More than one site domain was returned. This was unexpected and needs to be corrected.', response=response)
else:
log.debug(site_domain_obj_result)
return mk_resp(data=False, status_code=404, response=response)
@@ -199,7 +203,7 @@ async def get_site_domain_obj(
site_domain_obj['site'] = site_obj
log.debug(site_domain_obj)
return mk_resp(data=site_domain_obj)
return mk_resp(data=site_domain_obj, response=response)
else:
log.debug(site_domain_obj_result)
return mk_resp(data=False, status_code=404, response=response)