A lot of code clean up! Also adding in Response everywhere...

This commit is contained in:
Scott Idem
2021-08-10 18:09:34 -04:00
parent 73466456ee
commit d933395a9f
57 changed files with 290 additions and 147 deletions

View File

@@ -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]

View File

@@ -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

View File

@@ -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]