From d933395a9f0ea93a2a5ad40c0fe54ae60fcd531a Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 10 Aug 2021 18:09:34 -0400 Subject: [PATCH] A lot of code clean up! Also adding in Response everywhere... --- app/lib_general.py | 2 +- app/main.py | 6 +-- app/methods/address_methods.py | 4 ++ app/methods/contact_methods.py | 23 ++++++---- app/methods/event_person_methods.py | 56 +++++++++++++----------- app/methods/order_cfg_methods.py | 2 +- app/methods/organization_methods.py | 2 + app/methods/person_methods.py | 25 +++++++---- app/methods/user_methods.py | 5 ++- app/models/event_person_models.py | 1 + app/models/response_models.py | 7 +-- app/models/user_models.py | 2 +- app/routers/account.py | 9 +++- app/routers/address.py | 8 +++- app/routers/api.py | 12 ++++- app/routers/api_crud.py | 20 ++++++--- app/routers/archive.py | 7 ++- app/routers/archive_content.py | 7 ++- app/routers/cont_edu_cert.py | 11 ++++- app/routers/cont_edu_cert_person.py | 15 +++++-- app/routers/contact.py | 12 +++-- app/routers/event.py | 4 +- app/routers/event_exhibit.py | 9 +++- app/routers/event_file.py | 5 ++- app/routers/event_person.py | 22 +++++++--- app/routers/event_person_detail.py | 7 ++- app/routers/event_presentation.py | 2 +- app/routers/event_presenter.py | 4 +- app/routers/event_registration.py | 2 +- app/routers/event_session.py | 4 +- app/routers/flask_cfg.py | 2 +- app/routers/hosted_file.py | 3 +- app/routers/importing.py | 4 +- app/routers/journal.py | 4 +- app/routers/journal_entry.py | 4 +- app/routers/log_client_viewing.py | 2 +- app/routers/lookup.py | 3 +- app/routers/membership_cfg.py | 2 +- app/routers/membership_group.py | 4 +- app/routers/membership_group_person.py | 2 +- app/routers/membership_person.py | 4 +- app/routers/membership_person_profile.py | 2 +- app/routers/membership_type.py | 4 +- app/routers/membership_type_person.py | 2 +- app/routers/order.py | 14 ++++-- app/routers/order_cart.py | 15 ++++--- app/routers/organization.py | 2 +- app/routers/page.py | 2 +- app/routers/person.py | 31 ++++++++----- app/routers/post.py | 2 +- app/routers/post_comment.py | 2 +- app/routers/product.py | 2 +- app/routers/site.py | 4 +- app/routers/site_domain.py | 4 +- app/routers/user.py | 14 +++--- app/routers/user_person.py | 4 +- app/routers/websockets.py | 4 +- 57 files changed, 290 insertions(+), 147 deletions(-) diff --git a/app/lib_general.py b/app/lib_general.py index d85a5b4..5fc4838 100644 --- a/app/lib_general.py +++ b/app/lib_general.py @@ -3,7 +3,7 @@ import datetime, jwt, pytz, redis, time from passlib.hash import argon2 #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Depends, Header, HTTPException, status +from fastapi import APIRouter, Depends, Header, HTTPException, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/main.py b/app/main.py index 3b215a7..a8d872d 100644 --- a/app/main.py +++ b/app/main.py @@ -2,7 +2,7 @@ import datetime, json, logging, os, pytz, random, secrets # , uvicorn from enum import Enum #from datetime import datetime, time, timedelta -from fastapi import Body, Cookie, Depends, FastAPI, File, Form, Header, HTTPException, Path, Query, Request, status, UploadFile +from fastapi import Body, Cookie, Depends, FastAPI, File, Form, Header, HTTPException, Path, Query, Request, Response, status, UploadFile from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, PlainTextResponse from fastapi.staticfiles import StaticFiles @@ -342,7 +342,7 @@ async def add_process_time_header(request: Request, call_next): # ### BEGIN ### API Main ### fastapi_root() ### @app.get('/', tags=['Root'], response_class=PlainTextResponse) -async def fastapi_root(): +async def fastapi_root(response: Response = Response): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARN, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -409,7 +409,7 @@ async def fastapi_root(): # ### BEGIN ### API Main ### sql_test() ### # ### TEST TEST TEST ### # @app.get('/sql_test', tags=['Testing'], response_class=PlainTextResponse) -async def sql_test(): +async def sql_test(response: Response = Response): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARN, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/methods/address_methods.py b/app/methods/address_methods.py index 04702c0..458dfb0 100644 --- a/app/methods/address_methods.py +++ b/app/methods/address_methods.py @@ -99,6 +99,8 @@ def get_address_rec_list( # ### BEGIN ### API Address Methods ### create_address_obj() ### +# NOTE: This will create an address. +# Reviewed and updated 2021-08-10 def create_address_obj(address_obj_new:Address_Base): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -122,6 +124,8 @@ def create_address_obj(address_obj_new:Address_Base): # ### BEGIN ### API Address Methods ### update_address_obj() ### +# NOTE: This will update an address. +# Reviewed and updated 2021-08-10 def update_address_obj( address_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value. address_obj_up: Address_Base, diff --git a/app/methods/contact_methods.py b/app/methods/contact_methods.py index a98ac25..b7f88a9 100644 --- a/app/methods/contact_methods.py +++ b/app/methods/contact_methods.py @@ -116,6 +116,8 @@ def get_contact_rec_list( # ### BEGIN ### API Contact Methods ### create_contact_obj() ### +# NOTE: This will create a contact and then also create a linked address if contact_obj.address data is passed. +# Reviewed and updated 2021-08-10 def create_contact_obj(contact_obj_new:Contact_Base): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -140,14 +142,15 @@ def create_contact_obj(contact_obj_new:Contact_Base): create_address_obj_result = create_address_obj(address_obj_new=address_obj_new) if isinstance(create_address_obj_result, int): address_id = create_address_obj_result + # NOTE: This last update should no longer be needed now that the contact.address_id is not supposed to be used. # Need to update the contact with the new address_id - contact_obj_up = {} - contact_obj_up['id'] = contact_id - contact_obj_up['address_id'] = address_id - if contact_obj_up_result := sql_update(data=contact_obj_up, table_name='contact'): pass - else: - return False - log.debug(contact_obj_up_result) + contact_obj_up = {} # REMOVE + contact_obj_up['id'] = contact_id # REMOVE + contact_obj_up['address_id'] = address_id # REMOVE + if contact_obj_up_result := sql_update(data=contact_obj_up, table_name='contact'): pass # REMOVE + else: # REMOVE + return False # REMOVE + log.debug(contact_obj_up_result) # REMOVE else: log.debug(f'No address_id was returned when tyring to create_address_obj(): {create_address_obj_result}') address_id = None @@ -158,6 +161,8 @@ def create_contact_obj(contact_obj_new:Contact_Base): # ### BEGIN ### API Contact Methods ### update_contact_obj() ### +# NOTE: This will update a contact and then also create or update a linked address if contact_obj.address data is passed. +# Reviewed and updated 2021-08-10 def update_contact_obj( contact_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value. contact_obj_up: Contact_Base, @@ -199,7 +204,9 @@ def update_contact_obj( if address_obj_in_result := create_address_obj(address_obj_new=address_obj_in): # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(address_obj_in_result) - contact_obj_up.address_id = address_obj_in_result + # NOTE: This last update should no longer be needed now that the contact.address_id is not supposed to be used. + # Need to update the contact with the new address_id + contact_obj_up.address_id = address_obj_in_result # REMOVE else: # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(address_obj_in_result) diff --git a/app/methods/event_person_methods.py b/app/methods/event_person_methods.py index d9ba74b..e791a8e 100644 --- a/app/methods/event_person_methods.py +++ b/app/methods/event_person_methods.py @@ -22,31 +22,6 @@ from app.methods.user_methods import create_user_obj, load_user_obj, update_user from app.models.event_person_models import Event_Person_New_Base, Event_Person_Base -# ### BEGIN ### API Event Person Methods ### create_event_person_obj() ### -def create_event_person_obj(event_person_obj_new:Event_Person_Base) -> int|bool: - log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL - log.debug(locals()) - - if not event_person_obj_new: - return False - - event_person_obj_data = event_person_obj_new.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'created_on', 'updated_on'}) - log.debug(event_person_obj_data) - - if event_person_obj_in_result := sql_insert(data=event_person_obj_data, table_name='event_person', rm_id_random=True, id_random_length=8): pass - else: - return False - - #log.setLevel(logging.DEBUG) - log.debug(event_person_obj_in_result) - - event_person_id = event_person_obj_in_result - - log.debug(f'Returning the new event_person_id: {event_person_id}') - return event_person_id -# ### END ### API Event Person Methods ### create_event_person_obj() ### - - # ### BEGIN ### API Event Person Methods ### load_event_person_obj() ### def load_event_person_obj( event_person_id: int|str, @@ -132,7 +107,38 @@ def load_event_person_obj( # ### END ### API Event Person Methods ### load_event_person_obj() ### +# ### BEGIN ### API Event Person Methods ### create_event_person_obj() ### +# NOTE: This will create an event_person. This event_person should include at least a person_id. +# NOTE: Is it a good idea to create and or update a person and or user here??? The create_event_person_obj() below does do that. +# Reviewed and updated 2021-08-10 +def create_event_person_obj(event_person_obj_new:Event_Person_Base) -> int|bool: + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + if not event_person_obj_new: + return False + + event_person_obj_data = event_person_obj_new.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'created_on', 'updated_on'}) + log.debug(event_person_obj_data) + + if event_person_obj_in_result := sql_insert(data=event_person_obj_data, table_name='event_person', rm_id_random=True, id_random_length=8): pass + else: + return False + + #log.setLevel(logging.DEBUG) + log.debug(event_person_obj_in_result) + + event_person_id = event_person_obj_in_result + + log.debug(f'Returning the new event_person_id: {event_person_id}') + return event_person_id +# ### END ### API Event Person Methods ### create_event_person_obj() ### + + # ### BEGIN ### API Event Person Methods ### update_event_person_obj() ### +# NOTE: This will update an event_person. This also tries to create or update a person or user if that data is passed. +# NOTE: Is it a good idea to create and or update a person and or user here??? +# Reviewed and updated 2021-08-10 def update_event_person_obj( event_person_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value. event_person_obj_up: Event_Person_Base, diff --git a/app/methods/order_cfg_methods.py b/app/methods/order_cfg_methods.py index 72db496..ac9a11a 100644 --- a/app/methods/order_cfg_methods.py +++ b/app/methods/order_cfg_methods.py @@ -17,7 +17,7 @@ def load_order_cfg_obj( exclude_unset: bool = True, model_as_dict: bool = True, ) -> Order_Cfg_Base|dict|bool: - log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + 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 diff --git a/app/methods/organization_methods.py b/app/methods/organization_methods.py index c8faa65..96b4ce7 100644 --- a/app/methods/organization_methods.py +++ b/app/methods/organization_methods.py @@ -122,6 +122,8 @@ def get_organization_rec_list( # ### BEGIN ### API Organization Methods ### update_organization_obj() ### +# NOTE: This will create an organization and then also create a linked contact if organization_obj.contact data is passed. The create_contact_obj will create a contact and then also create a linked address if organization_obj.contact.address data is passed. +# Reviewed and updated 2021-08-10 def update_organization_obj( organization_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value. organization_obj_up: Organization_Base, diff --git a/app/methods/person_methods.py b/app/methods/person_methods.py index 06c66c3..8ced9e6 100644 --- a/app/methods/person_methods.py +++ b/app/methods/person_methods.py @@ -293,6 +293,8 @@ def get_person_rec_list( # ### BEGIN ### API Person Methods ### create_person_obj() ### +# NOTE: This will create a person and then also create a linked contact if person_obj.contact data is passed. The create_contact_obj will create a contact and then also create a linked address if person_obj.contact.address data is passed. +# Reviewed and updated 2021-08-10 def create_person_obj(person_obj_new:Person_Base): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -319,14 +321,15 @@ def create_person_obj(person_obj_new:Person_Base): if isinstance(create_contact_obj_result, int): contact_id = create_contact_obj_result log.debug(f'Update person with new contact_id: {contact_id}') + # NOTE: This last update should no longer be needed now that the person.contact_id is not supposed to be used. # Need to update the person with the new contact_id - person_obj_up = {} - person_obj_up['id'] = person_id - person_obj_up['contact_id_old'] = contact_id - if person_obj_up_result := sql_update(data=person_obj_up, table_name='person'): pass - else: - return False - log.debug(person_obj_up_result) + person_obj_up = {} # REMOVE + person_obj_up['id'] = person_id # REMOVE + person_obj_up['contact_id_old'] = contact_id # REMOVE + if person_obj_up_result := sql_update(data=person_obj_up, table_name='person'): pass # REMOVE + else: # REMOVE + return False # REMOVE + log.debug(person_obj_up_result) # REMOVE else: log.debug(f'No contact_id was returned when tyring to create_contact_obj(): {create_contact_obj_result}') contact_id = None @@ -337,6 +340,8 @@ def create_person_obj(person_obj_new:Person_Base): # ### BEGIN ### API Person Methods ### update_person_obj() ### +# NOTE: This will update a person and then also create or update a linked contact if person_obj.contact data is passed. The create_contact_obj will create a contact and then also create a linked address if person_obj.contact.address data is passed. The update_contact_obj will update a contact and then also create or update a linked address if person_obj.contact.address data is passed. +# Reviewed and updated 2021-08-10 def update_person_obj( person_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value. person_obj_up: Person_Base, @@ -376,7 +381,9 @@ def update_person_obj( if contact_obj_in_result := create_contact_obj(contact_obj_new=contact_obj_in): # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(contact_obj_in_result) - person_obj_up.contact_id = contact_obj_in_result + # NOTE: This last update should no longer be needed now that the person.contact_id is not supposed to be used. + # Need to update the person with the new contact_id + person_obj_up.contact_id = contact_obj_in_result # REMOVE else: # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(contact_obj_in_result) @@ -403,6 +410,7 @@ def update_person_obj( if organization_obj_in_result := create_organization_obj(organization_obj_new=organization_obj_in): # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(organization_obj_in_result) + # Need to update the person with the new organization_id person_obj_up.organization_id = organization_obj_in_result else: # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL @@ -431,6 +439,7 @@ def update_person_obj( if user_obj_in_result := create_user_obj(user_obj_new=user_obj_in): # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(user_obj_in_result) + # Need to update the person with the new user_id person_obj_up.user_id = user_obj_in_result else: # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL diff --git a/app/methods/user_methods.py b/app/methods/user_methods.py index d745904..13225e0 100644 --- a/app/methods/user_methods.py +++ b/app/methods/user_methods.py @@ -19,6 +19,9 @@ from app.models.user_models import User_Base, User_New_Base, User_Out_Base # ### BEGIN ### API User Methods ### create_user_obj() ### +# NOTE: This will create a new user and also hash a new password string if given. +# NOTE: This uses the User_New_Base model, not User_Base or User_Out_Base +# Reviewed and updated 2021-08-10 def create_user_obj(user_obj_new:User_New_Base) -> int|bool: log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -27,8 +30,6 @@ def create_user_obj(user_obj_new:User_New_Base) -> int|bool: return False # user_obj_data = user_obj_new.dict(by_alias=False, exclude_defaults=False, include={'password'}, exclude={'new_password'}) - # log.debug(user_obj_data) - user_obj_data = user_obj_new.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'new_password'}) log.debug(user_obj_data) diff --git a/app/models/event_person_models.py b/app/models/event_person_models.py index 1444bc3..3aeda35 100644 --- a/app/models/event_person_models.py +++ b/app/models/event_person_models.py @@ -170,6 +170,7 @@ class Event_Person_New_Base(BaseModel): person_given_name: Optional[str] person_family_name: Optional[str] person_full_name: Optional[str] + person_display_name: Optional[str] organization_name: Optional[str] diff --git a/app/models/response_models.py b/app/models/response_models.py index d57bed9..aba2407 100644 --- a/app/models/response_models.py +++ b/app/models/response_models.py @@ -5,7 +5,7 @@ from typing import Dict, List, Optional, Set, Union from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationError, validator from app.db_sql import redis_lookup_id_random -from app.lib_general import log, logging, status +from app.lib_general import log, logging, Response, status from app.config import settings @@ -39,9 +39,9 @@ def mk_resp( details: str = '', by_alias: bool = True, exclude_unset: bool = True, - response = None + response: Response = None ): - log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) if data is None: data_out = { 'result': data } @@ -83,6 +83,7 @@ def mk_resp( resp_body['meta']['data_list_count'] = len(data) if response: + log.debug(response) if status_code == 400: response.status_code = status.HTTP_400_BAD_REQUEST elif status_code == 401: response.status_code = status.HTTP_401_UNAUTHORIZED elif status_code == 403: response.status_code = status.HTTP_403_FORBIDDEN diff --git a/app/models/user_models.py b/app/models/user_models.py index c96dcee..bd9ddd7 100644 --- a/app/models/user_models.py +++ b/app/models/user_models.py @@ -44,7 +44,7 @@ class User_New_Base(BaseModel): name: str email: str new_password: str = Field(default_factory = lambda:secrets.token_urlsafe(default_num_bytes)) - password: Optional[str] + password: Optional[str] # If new_password is found then the validator below will create secure_hash_string() from the new password string. allow_auth_key: Optional[int] diff --git a/app/routers/account.py b/app/routers/account.py index f7ec29b..ba87a3e 100644 --- a/app/routers/account.py +++ b/app/routers/account.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -31,6 +31,7 @@ async def post_account_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -55,6 +56,7 @@ async def patch_account_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -81,6 +83,7 @@ async def get_account_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -176,6 +179,7 @@ async def get_account_obj_new( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -317,6 +321,7 @@ async def get_account_obj_event_list( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -386,6 +391,7 @@ async def get_account_obj_event_list( async def delete_account_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -405,6 +411,7 @@ async def get_account_cfg_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/address.py b/app/routers/address.py index c8443cc..fab31b0 100644 --- a/app/routers/address.py +++ b/app/routers/address.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -28,6 +28,7 @@ async def post_address_obj( #exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -52,6 +53,7 @@ async def patch_address_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -84,6 +86,7 @@ async def patch_address_json( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -120,6 +123,7 @@ async def get_address_obj_li( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -144,6 +148,7 @@ async def get_address_obj( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -162,6 +167,7 @@ async def get_address_obj( async def delete_address_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/api.py b/app/routers/api.py index 9f7e785..c3d16d0 100644 --- a/app/routers/api.py +++ b/app/routers/api.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -45,6 +45,7 @@ async def request_jwt( max_ttl: int = 300, # Number of seconds to live. Only use if given the API secret key. # Seconds: 3600 = 1 hr; 300 = 5 min max_renew: int = 5, # Decrease count by 1 until 0 if only sent a current API token. + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -136,6 +137,7 @@ async def get_api_temp_token( x_aether_api_key: Optional[str] = Header(None), x_aether_api_token: Optional[str] = Header(None), x_aether_api_token_expire_on: Optional[str] = Header(None), + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -162,7 +164,7 @@ async def get_api_temp_token( return mk_resp(data=resp_data) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) #obj_type = 'api' #result = get_obj_template( @@ -181,6 +183,7 @@ async def post_api_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -205,6 +208,7 @@ async def patch_api_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -231,6 +235,7 @@ async def get_api_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -252,6 +257,7 @@ async def get_api_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -270,6 +276,7 @@ async def get_api_obj( async def delete_api_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -289,6 +296,7 @@ async def get_api_object_id( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/api_crud.py b/app/routers/api_crud.py index f06e4e2..6fdf282 100644 --- a/app/routers/api_crud.py +++ b/app/routers/api_crud.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -164,6 +164,7 @@ async def get_obj_li( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -243,6 +244,7 @@ async def get_obj( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): """ Simple select object type with an ID: @@ -309,7 +311,7 @@ async def get_obj( return mk_resp(data=resp_data) #, details=debug_data) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) @router.delete('/{obj_type_l1}/{obj_id}') @@ -321,6 +323,7 @@ async def delete_obj( obj_type_l3: str=None, obj_id: str=None, x_account_id: str = Header(...), + response: Response = Response, ): """ Simple delete object type with an ID: @@ -389,6 +392,7 @@ def post_obj_template( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -416,7 +420,7 @@ def post_obj_template( return mk_resp(data=resp_data) else: log.debug(sql_select_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) def patch_obj_template( @@ -429,6 +433,7 @@ def patch_obj_template( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -461,7 +466,7 @@ def patch_obj_template( return mk_resp(data=resp_data) else: log.debug(sql_select_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) def get_obj_li_template( @@ -473,6 +478,7 @@ def get_obj_li_template( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -512,6 +518,7 @@ def get_obj_template( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -538,12 +545,13 @@ def get_obj_template( return mk_resp(data=resp_data) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) def delete_obj_template( obj_type: str = Query(None, max_length=50), obj_id: str = Query(None, max_length=22), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -562,4 +570,4 @@ def delete_obj_template( return mk_resp(data=True) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) \ No newline at end of file + return mk_resp(data=False, status_code=404, response=response) \ No newline at end of file diff --git a/app/routers/archive.py b/app/routers/archive.py index a080167..0a41af9 100644 --- a/app/routers/archive.py +++ b/app/routers/archive.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -25,6 +25,7 @@ async def post_archive_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -49,6 +50,7 @@ async def patch_archive_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -75,6 +77,7 @@ async def get_archive_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -96,6 +99,7 @@ async def get_archive_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -114,6 +118,7 @@ async def get_archive_obj( async def delete_archive_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/archive_content.py b/app/routers/archive_content.py index 660c680..6928839 100644 --- a/app/routers/archive_content.py +++ b/app/routers/archive_content.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -25,6 +25,7 @@ async def post_archive_content_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -49,6 +50,7 @@ async def patch_archive_content_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -75,6 +77,7 @@ async def get_archive_content_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -96,6 +99,7 @@ async def get_archive_content_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -114,6 +118,7 @@ async def get_archive_content_obj( async def delete_archive_content_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/cont_edu_cert.py b/app/routers/cont_edu_cert.py index cb1b24c..128bd45 100644 --- a/app/routers/cont_edu_cert.py +++ b/app/routers/cont_edu_cert.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -25,6 +25,7 @@ async def post_cont_edu_cert_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -49,6 +50,7 @@ async def patch_cont_edu_cert_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -81,6 +83,7 @@ async def patch_cont_edu_cert_json( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -115,6 +118,7 @@ async def get_cont_edu_cert_obj_li( x_account_id: str = Header(...), by_alias: bool = True, exclude_unset: bool = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -157,7 +161,7 @@ async def get_cont_edu_cert_obj_li( return mk_resp(data=resp_data_li) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) result = get_obj_li_template( obj_type=obj_type, @@ -175,6 +179,7 @@ async def get_cont_edu_cert_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -200,6 +205,7 @@ async def get_account_obj_cont_edu_cert_list( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -242,6 +248,7 @@ async def get_account_obj_cont_edu_cert_list( async def delete_cont_edu_cert_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/cont_edu_cert_person.py b/app/routers/cont_edu_cert_person.py index 2b19aab..0447b3b 100644 --- a/app/routers/cont_edu_cert_person.py +++ b/app/routers/cont_edu_cert_person.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -25,6 +25,7 @@ async def post_cont_edu_cert_person_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -49,6 +50,7 @@ async def patch_cont_edu_cert_person_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -81,6 +83,7 @@ async def patch_cont_edu_cert_person_json( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -115,6 +118,7 @@ async def get_cont_edu_cert_person_obj_li( x_account_id: str = Header(...), by_alias: bool = True, exclude_unset: bool = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -157,7 +161,7 @@ async def get_cont_edu_cert_person_obj_li( return mk_resp(data=resp_data_li) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) result = get_obj_li_template( obj_type=obj_type, @@ -186,6 +190,7 @@ async def search_cont_edu_cert_person_obj_li( x_account_id: str = Header(...), by_alias: bool = True, exclude_unset: bool = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -269,7 +274,7 @@ async def search_cont_edu_cert_person_obj_li( return mk_resp(data=resp_data_li) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) # ### END ### API Cont Edu Cert Person ### search_cont_edu_cert_person_obj_li() ### @@ -284,6 +289,7 @@ async def get_cont_edu_cert_person_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -316,6 +322,7 @@ async def get_account_obj_cont_edu_cert_person_list( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -365,6 +372,7 @@ async def get_cont_edu_cert_obj_cont_edu_cert_person_list( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -407,6 +415,7 @@ async def get_cont_edu_cert_obj_cont_edu_cert_person_list( async def delete_cont_edu_cert_person_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/contact.py b/app/routers/contact.py index c0164ec..c1315de 100644 --- a/app/routers/contact.py +++ b/app/routers/contact.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -25,6 +25,7 @@ async def post_contact_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -49,6 +50,7 @@ async def patch_contact_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -81,6 +83,7 @@ async def patch_contact_json( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -115,6 +118,7 @@ async def get_contact_obj_li( x_account_id: str = Header(...), by_alias: bool = True, exclude_unset: bool = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -157,7 +161,7 @@ async def get_contact_obj_li( return mk_resp(data=resp_data_li) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) result = get_obj_li_template( obj_type=obj_type, @@ -175,6 +179,7 @@ async def get_contact_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -193,6 +198,7 @@ async def get_contact_obj( async def delete_contact_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -202,4 +208,4 @@ async def delete_contact_obj( obj_type=obj_type, obj_id=obj_id, ) - return result \ No newline at end of file + return result diff --git a/app/routers/event.py b/app/routers/event.py index c9627a6..c238e29 100644 --- a/app/routers/event.py +++ b/app/routers/event.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -246,7 +246,7 @@ async def get_event_obj_li( return mk_resp(data=event_obj_li) else: log.debug(event_obj_li_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) # ### BEGIN ### API Event ### get_event_obj() ### diff --git a/app/routers/event_exhibit.py b/app/routers/event_exhibit.py index 3264c8b..7132fd5 100644 --- a/app/routers/event_exhibit.py +++ b/app/routers/event_exhibit.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -24,6 +24,7 @@ async def post_event_exhibit_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -48,6 +49,7 @@ async def patch_event_exhibit_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -74,6 +76,7 @@ async def get_event_exhibit_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -95,6 +98,7 @@ async def get_event_exhibit_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -113,6 +117,7 @@ async def get_event_exhibit_obj( async def delete_event_exhibit_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -122,4 +127,4 @@ async def delete_event_exhibit_obj( obj_type=obj_type, obj_id=obj_id, ) - return result \ No newline at end of file + return result diff --git a/app/routers/event_file.py b/app/routers/event_file.py index c88c2e3..4bedaca 100644 --- a/app/routers/event_file.py +++ b/app/routers/event_file.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -25,6 +25,7 @@ async def post_event_file_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -49,6 +50,7 @@ async def patch_event_file_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -72,6 +74,7 @@ async def patch_event_file_obj( async def delete_event_file_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/event_person.py b/app/routers/event_person.py index 712dff4..1d9b79d 100644 --- a/app/routers/event_person.py +++ b/app/routers/event_person.py @@ -1,5 +1,5 @@ import datetime, secrets -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -42,10 +42,15 @@ async def post_event_person_new( inc_user: bool = False, by_alias: bool = True, exclude_unset: 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()) + log.debug(event_person_new_init) + log.debug(vars(event_person_new_init)) + log.debug(dir(event_person_new_init)) + account_id_random = event_person_new_init.account_id_random event_id_random = event_person_new_init.event_id_random @@ -57,6 +62,7 @@ async def post_event_person_new( full_name = f'{given_name} {family_name}' elif given_name: full_name = f'{given_name}' + display_name = event_person_new_init.person_display_name email = event_person_new_init.email if new_password := event_person_new_init.new_password: @@ -72,6 +78,7 @@ async def post_event_person_new( person_new['given_name'] = given_name person_new['family_name'] = family_name person_new['full_name'] = full_name + person_new['display_name'] = display_name person_new['organization_name'] = organization_name # New person contact @@ -88,6 +95,8 @@ async def post_event_person_new( person_obj_new = Person_Base(**person_new) log.debug(person_obj_new) + return mk_resp(data=False, status_code=401) # TESTING TESTING TESTING + create_person_obj_result = create_person_obj(person_obj_new=person_obj_new) if isinstance(create_person_obj_result, int): person_id = create_person_obj_result @@ -109,9 +118,9 @@ async def post_event_person_new( user_new['name'] = full_name user_new['username'] = email user_new['email'] = email - user_new['new_password'] = new_password - user_new['contact_id_random'] = person_obj.contact.id_random - user_new['person_id_random'] = person_obj.id_random + user_new['new_password'] = new_password # The string will be turned into a secure hash and stored in user.password. + # user_new['contact_id_random'] = person_obj.contact.id_random # REMOVE: No longer used + # user_new['person_id_random'] = person_obj.id_random # REMOVE: No longer used log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(user_new) @@ -217,6 +226,7 @@ async def patch_event_person_json( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -268,6 +278,7 @@ async def get_event_person_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -328,6 +339,7 @@ async def get_person_event_person_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/event_person_detail.py b/app/routers/event_person_detail.py index 722fc93..3afd0ae 100644 --- a/app/routers/event_person_detail.py +++ b/app/routers/event_person_detail.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -25,6 +25,7 @@ async def post_event_person_detail_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -49,6 +50,7 @@ async def patch_event_person_detail_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -75,6 +77,7 @@ async def get_event_person_detail_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -96,6 +99,7 @@ async def get_event_person_detail_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -114,6 +118,7 @@ async def get_event_person_detail_obj( async def delete_event_person_detail_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/event_presentation.py b/app/routers/event_presentation.py index 3831ff3..b57d991 100644 --- a/app/routers/event_presentation.py +++ b/app/routers/event_presentation.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/event_presenter.py b/app/routers/event_presenter.py index 53b566e..5798de4 100644 --- a/app/routers/event_presenter.py +++ b/app/routers/event_presenter.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -203,7 +203,7 @@ async def get_event_presenter_obj_li( return mk_resp(data=event_presenter_li) else: log.debug(event_presenter_li_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) # @router.get('/{obj_id}', response_model=Resp_Body_Base) diff --git a/app/routers/event_registration.py b/app/routers/event_registration.py index 18200f1..f9a8622 100644 --- a/app/routers/event_registration.py +++ b/app/routers/event_registration.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/event_session.py b/app/routers/event_session.py index 34399a9..4e5da4c 100644 --- a/app/routers/event_session.py +++ b/app/routers/event_session.py @@ -1,5 +1,5 @@ import datetime, json -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -250,7 +250,7 @@ async def get_event_session_obj_li( return mk_resp(data=event_session_li) else: log.debug(event_session_li_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) # ### BEGIN ### API Event Session ### get_event_session_obj() ### diff --git a/app/routers/flask_cfg.py b/app/routers/flask_cfg.py index cca7529..b3fa0a5 100644 --- a/app/routers/flask_cfg.py +++ b/app/routers/flask_cfg.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/hosted_file.py b/app/routers/hosted_file.py index a0a5aff..516c00b 100644 --- a/app/routers/hosted_file.py +++ b/app/routers/hosted_file.py @@ -165,6 +165,7 @@ async def upload_files_fake( return_obj: bool = True, by_alias: bool = True, exclude_unset: bool = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -284,7 +285,7 @@ async def test_upload_files( file_list: List[UploadFile], # account_id: str = Form(..., min_length=1, max_length=22), # filename: Optional[str] = Form(...), - + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/importing.py b/app/routers/importing.py index bf8585b..5dcafce 100644 --- a/app/routers/importing.py +++ b/app/routers/importing.py @@ -1,6 +1,6 @@ import datetime, json, pytz, secrets, time import pandas, xlrd # qrcode -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -26,6 +26,7 @@ router = APIRouter() @router.post('/person_data', response_model=Resp_Body_Base) async def importing_person_data( + response: Response = Response, ): log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -335,6 +336,7 @@ async def importing_person_data( @router.post('/cont_edu_cert_person_data', response_model=Resp_Body_Base) async def importing_cont_edu_cert_person_data( + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/journal.py b/app/routers/journal.py index fc04e24..a1d5cc3 100644 --- a/app/routers/journal.py +++ b/app/routers/journal.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -122,7 +122,7 @@ async def get_journal_obj_li( return mk_resp(data=resp_data_li) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) @router.get('/{obj_id}', response_model=Resp_Body_Base) diff --git a/app/routers/journal_entry.py b/app/routers/journal_entry.py index a3d8c14..e055b87 100644 --- a/app/routers/journal_entry.py +++ b/app/routers/journal_entry.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -123,7 +123,7 @@ async def get_journal_entry_obj_li( return mk_resp(data=resp_data_li) else: log.debug(sql_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) @router.get('/journal/entry/{obj_id}', response_model=Resp_Body_Base) diff --git a/app/routers/log_client_viewing.py b/app/routers/log_client_viewing.py index cd98af8..d97f3ab 100644 --- a/app/routers/log_client_viewing.py +++ b/app/routers/log_client_viewing.py @@ -1,5 +1,5 @@ import datetime, pytz, time -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/lookup.py b/app/routers/lookup.py index 09b038c..4d94329 100644 --- a/app/routers/lookup.py +++ b/app/routers/lookup.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -26,6 +26,7 @@ async def get_lookup_li( inc_admin_options: bool = False, limit: int = 1000, enabled: str = 'enabled', # enabled, disabled, all + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/membership_cfg.py b/app/routers/membership_cfg.py index 12e3fa3..32be5c3 100644 --- a/app/routers/membership_cfg.py +++ b/app/routers/membership_cfg.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/membership_group.py b/app/routers/membership_group.py index 46eb64b..cc36b75 100644 --- a/app/routers/membership_group.py +++ b/app/routers/membership_group.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -175,7 +175,7 @@ async def lookup_membership_group_obj( base_name = Membership_Group_Base if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass - else: return mk_resp(data=False, status_code=404) # Not Found + else: return mk_resp(data=False, status_code=404, response=response) # Not Found log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL data = {} diff --git a/app/routers/membership_group_person.py b/app/routers/membership_group_person.py index 42df866..7c9ffed 100644 --- a/app/routers/membership_group_person.py +++ b/app/routers/membership_group_person.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/membership_person.py b/app/routers/membership_person.py index 471cf36..1db71ee 100644 --- a/app/routers/membership_person.py +++ b/app/routers/membership_person.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -265,7 +265,7 @@ async def lookup_membership_person_obj( base_name = Membership_Person_Base if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass - else: return mk_resp(data=False, status_code=404) # Not Found + else: return mk_resp(data=False, status_code=404, response=response) # Not Found log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL data = {} diff --git a/app/routers/membership_person_profile.py b/app/routers/membership_person_profile.py index 3e6e1b8..7fdfb51 100644 --- a/app/routers/membership_person_profile.py +++ b/app/routers/membership_person_profile.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/membership_type.py b/app/routers/membership_type.py index 720b62b..5016f80 100644 --- a/app/routers/membership_type.py +++ b/app/routers/membership_type.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -175,7 +175,7 @@ async def lookup_membership_type_obj( base_name = Membership_Type_Base if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass - else: return mk_resp(data=False, status_code=404) # Not Found + else: return mk_resp(data=False, status_code=404, response=response) # Not Found # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL data = {} diff --git a/app/routers/membership_type_person.py b/app/routers/membership_type_person.py index 3ff65ca..9bda1a1 100644 --- a/app/routers/membership_type_person.py +++ b/app/routers/membership_type_person.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/order.py b/app/routers/order.py index c0f8b3a..7dc46d7 100644 --- a/app/routers/order.py +++ b/app/routers/order.py @@ -1,5 +1,5 @@ import datetime -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -27,6 +27,7 @@ async def post_order_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -52,6 +53,7 @@ async def patch_order_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -82,6 +84,7 @@ async def patch_order_obj_line_add( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -103,6 +106,7 @@ async def get_order_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -175,7 +179,7 @@ async def get_order_obj_li( return mk_resp(data=order_obj_li) else: log.debug(order_obj_li_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) # ### BEGIN ### API Order Routes ### get_order_obj() ### @@ -192,6 +196,7 @@ async def get_order_obj( x_account_id: str = Header(...), by_alias: bool = True, exclude_unset: bool = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -211,7 +216,7 @@ async def get_order_obj( data = order_obj.dict(by_alias=by_alias, exclude_unset=False) # NOTE NOTE NOTE NOTE exclude_unset is forced to False for now. Will return more fields than is ideal. Need to create another Order_Line_Base. Probably Order_Line_OUT_Base return mk_resp(data=data) else: - return mk_resp(data=False, status_code=404) # Not Found + return mk_resp(data=False, status_code=404, response=response) # Not Found # ### END ### API Order Routes ### get_order_obj() ### @@ -225,6 +230,7 @@ async def get_person_id_order_open_obj( x_account_id: str = Header(...), by_alias: bool = True, exclude_unset: bool = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -236,6 +242,7 @@ async def get_person_id_order_open_obj( async def delete_order_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -258,6 +265,7 @@ async def delete_order_line_obj_NOT_SURE( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/order_cart.py b/app/routers/order_cart.py index 6ca4c58..ebb3182 100644 --- a/app/routers/order_cart.py +++ b/app/routers/order_cart.py @@ -27,6 +27,7 @@ async def post_order_cart_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -56,6 +57,7 @@ async def patch_order_cart_obj( inc_order_cfg: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -85,7 +87,7 @@ async def patch_order_cart_obj( data = order_cart_obj.dict(by_alias=True, exclude_unset=False) return mk_resp(data=data) else: - return mk_resp(data=False, status_code=404) # Not Found + return mk_resp(data=False, status_code=404, response=response) # Not Found else: return mk_resp(data=True) @@ -97,6 +99,7 @@ async def get_order_cart_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -115,7 +118,6 @@ async def get_order_cart_obj_li( # Look up is only for account, order, person, or user records @router.get('/lookup', response_model=Resp_Body_Base) async def lookup_order_cart_obj( - response: Response, for_obj_type: Optional[str] = Query(None, min_length=2, max_length=50), for_obj_id: Optional[Union[int,str]] = None, inc_order_cart_line_list: Optional[bool] = True, @@ -123,6 +125,7 @@ async def lookup_order_cart_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -131,7 +134,7 @@ async def lookup_order_cart_obj( base_name = Order_Cart_Base if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass - else: return mk_resp(data=False, status_code=404) # Not Found + else: return mk_resp(data=False, status_code=404, response=response) # Not Found log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL data = {} @@ -178,7 +181,7 @@ async def lookup_order_cart_obj( data = order_cart_obj.dict(by_alias=True, exclude_unset=False) return mk_resp(data=data) else: - return mk_resp(data=False, status_code=404) # Not Found + return mk_resp(data=False, status_code=404, response=response) # Not Found elif isinstance(order_cart_obj_result, list): order_cart_obj_li = [] for order_cart_obj in order_cart_obj_result: @@ -209,6 +212,7 @@ async def get_order_cart_obj( x_account_id: str = Header(...), by_alias: bool = True, exclude_unset: bool = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -226,7 +230,7 @@ async def get_order_cart_obj( data = order_cart_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) return mk_resp(data=data) else: - return mk_resp(data=False, status_code=404) # Not Found + return mk_resp(data=False, status_code=404, response=response) # Not Found # ### END ### API Order Cart Routes ### get_order_cart_obj() ### @@ -234,6 +238,7 @@ async def get_order_cart_obj( async def delete_order_cart_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/organization.py b/app/routers/organization.py index 3844755..214c974 100644 --- a/app/routers/organization.py +++ b/app/routers/organization.py @@ -1,5 +1,5 @@ import datetime, pytz, time -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/page.py b/app/routers/page.py index f3e9b52..7a2894a 100644 --- a/app/routers/page.py +++ b/app/routers/page.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/person.py b/app/routers/person.py index f3a1c51..cb0826b 100644 --- a/app/routers/person.py +++ b/app/routers/person.py @@ -1,5 +1,5 @@ import datetime, pytz, time -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -27,6 +27,7 @@ async def post_person_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -51,6 +52,7 @@ async def patch_person_obj( return_obj: Optional[bool] = True, by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -86,6 +88,7 @@ async def post_person_json( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -107,7 +110,7 @@ async def post_person_json( else: return mk_resp(data=person_obj_in_result) else: - return mk_resp(data=False, status_code=400) # Bad Request + return mk_resp(data=False, status_code=400, response=response) # Bad Request # ### END ### API Person ### post_person_json() ### @@ -126,12 +129,13 @@ async def patch_person_json( exclude: Optional[list] = [], exclude_unset: Optional[bool] = True, exclude_none: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass - else: return mk_resp(data=None, status_code=404) + else: return mk_resp(data=None, status_code=404, response=response) if person_obj_up_result := create_update_person_obj( person_id = person_id, @@ -147,7 +151,7 @@ async def patch_person_json( else: return mk_resp(data=person_obj_up_result) else: - return mk_resp(data=False, status_code=400) # Bad Request + return mk_resp(data=False, status_code=400, response=response) # Bad Request # ### END ### API Person ### patch_person_json() ### @@ -159,6 +163,7 @@ async def get_person_obj_li( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -209,12 +214,13 @@ async def get_person_obj( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[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()) if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass - else: return mk_resp(data=None, status_code=404) + else: return mk_resp(data=None, status_code=404, response=response) if person_dict := load_person_obj( person_id = person_id, @@ -248,7 +254,7 @@ async def get_person_obj( else: response_data = person_dict else: - return mk_resp(data=False, status_code=400) # Bad Request + return mk_resp(data=False, status_code=400, response=response) # Bad Request return mk_resp(data=response_data) # ### END ### API Person ### get_person_obj() ### @@ -274,13 +280,14 @@ async def get_person_obj_order_list( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass else: - return mk_resp(data=None, status_code=404) + return mk_resp(data=None, status_code=404, response=response) # Updated 2021-06-28 if order_rec_list_result := get_order_rec_list( @@ -309,7 +316,7 @@ async def get_person_obj_order_list( order_result_list.append(None) response_data = order_result_list else: - return mk_resp(data=False, status_code=400) # Bad Request + return mk_resp(data=False, status_code=400, response=response) # Bad Request return mk_resp(data=response_data) # ### END ### API Person ### get_person_obj_order_list() ### @@ -338,12 +345,13 @@ async def get_account_obj_person_list( x_account_id: str = Header(...), by_alias: Optional[bool] = True, exclude_unset: Optional[bool] = True, + response: Response = Response, ): 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) + else: return mk_resp(data=None, status_code=404, response=response) response_data = None # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL @@ -374,7 +382,7 @@ async def get_account_obj_person_list( person_result_list.append(None) response_data = person_result_list else: - return mk_resp(data=False, status_code=400) # Bad Request + return mk_resp(data=False, status_code=400, response=response) # Bad Request return mk_resp(data=response_data) # ### END ### API Person ### get_account_obj_person_list() ### @@ -384,6 +392,7 @@ async def get_account_obj_person_list( async def delete_person_obj( obj_id: str = Query(..., min_length=1, max_length=22), x_account_id: str = Header(...), + response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) diff --git a/app/routers/post.py b/app/routers/post.py index 3c82fa2..bdd848e 100644 --- a/app/routers/post.py +++ b/app/routers/post.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/post_comment.py b/app/routers/post_comment.py index 309aaa1..93c4196 100644 --- a/app/routers/post_comment.py +++ b/app/routers/post_comment.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/product.py b/app/routers/product.py index c04780e..9ba490b 100644 --- a/app/routers/product.py +++ b/app/routers/product.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union diff --git a/app/routers/site.py b/app/routers/site.py index bfdbb14..82b6410 100644 --- a/app/routers/site.py +++ b/app/routers/site.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -167,4 +167,4 @@ async def delete_site_obj( # return mk_resp(data=order_obj_li) # else: # log.debug(order_obj_li_result) -# return mk_resp(data=False, status_code=404) +# return mk_resp(data=False, status_code=404, response=response) diff --git a/app/routers/site_domain.py b/app/routers/site_domain.py index 1b520ae..83036a1 100644 --- a/app/routers/site_domain.py +++ b/app/routers/site_domain.py @@ -1,6 +1,6 @@ import datetime #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -130,7 +130,7 @@ async def lookup_site_domain_obj( return mk_resp(data=site_domain_obj) else: log.debug(site_domain_obj_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) @router.get('/list', response_model=Resp_Body_Base) diff --git a/app/routers/user.py b/app/routers/user.py index 6c1b35f..b4daf62 100644 --- a/app/routers/user.py +++ b/app/routers/user.py @@ -1,5 +1,5 @@ import datetime, pytz, secrets, time -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -100,7 +100,7 @@ async def change_user_obj_password( password = secrets.token_urlsafe(default_num_bytes) if user_id := redis_lookup_id_random(record_id_random=user_id, table_name='user'): pass - else: return mk_resp(data=False, status_code=404) # Not Found + else: return mk_resp(data=False, status_code=404, response=response) # Not Found user_data = {} #user_data['user_id'] = user_id @@ -188,7 +188,7 @@ async def user_new_auth_key( log.info('The user record was not updated with a new auth_key') log.debug(user_rec_update_result) - return mk_resp(data=False, status_code=404) + return mk_resp(data=False, status_code=404, response=response) # ### BEGIN ### API User Routers ### user_authenticate() ### @@ -215,7 +215,7 @@ async def user_authenticate( if account_id and username and password: if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass - else: return mk_resp(data=False, status_code=404) # Not Found + else: return mk_resp(data=False, status_code=404, response=response) # Not Found user_data = {} user_data['account_id'] = account_id @@ -351,7 +351,7 @@ async def lookup_user_obj( base_name = User_Out_Base if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass - else: return mk_resp(data=False, status_code=404) # Not Found + else: return mk_resp(data=False, status_code=404, response=response) # Not Found log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL data = {} @@ -429,7 +429,7 @@ async def lookup_email( elif account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass else: - return mk_resp(data=False, status_code=404) # Not Found + return mk_resp(data=False, status_code=404, response=response) # Not Found log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL data = {} @@ -506,7 +506,7 @@ async def lookup_username( elif account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass else: - return mk_resp(data=False, status_code=404) # Not Found + return mk_resp(data=False, status_code=404, response=response) # Not Found log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL data = {} diff --git a/app/routers/user_person.py b/app/routers/user_person.py index d823c72..648cd6e 100644 --- a/app/routers/user_person.py +++ b/app/routers/user_person.py @@ -1,6 +1,6 @@ import datetime, pytz, time #from datetime import datetime, time, timedelta -from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union @@ -43,7 +43,7 @@ async def lookup_email( if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass else: - return mk_resp(data=False, status_code=404) # Not Found + return mk_resp(data=False, status_code=404, response=response) # Not Found log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL data = {} diff --git a/app/routers/websockets.py b/app/routers/websockets.py index 74cdb4a..f7e5b60 100644 --- a/app/routers/websockets.py +++ b/app/routers/websockets.py @@ -56,14 +56,14 @@ html = """ @router.get("/ws_test") -async def get(): +async def get(response: Response = Response): log.setLevel(logging.DEBUG) log.debug(locals()) return HTMLResponse(html) @router.websocket("/ws") -async def websocket_endpoint(websocket: WebSocket): +async def websocket_endpoint(websocket: WebSocket, response: Response = Response): log.setLevel(logging.DEBUG) log.debug(locals()) log.info('Root of ws. Waiting to accept a websocket and then the redis_connector')