Work membership and general clean up
This commit is contained in:
@@ -5,13 +5,13 @@ from typing import Dict, List, Optional, Set, Union
|
||||
from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationError, validator
|
||||
|
||||
from ..lib_general import *
|
||||
from ..log import *
|
||||
|
||||
from app.config import settings
|
||||
|
||||
from .common_field_schema import base_fields, default_num_bytes
|
||||
|
||||
|
||||
# ### BEGIN ### API Response Model ### Resp_Body_Base() ###
|
||||
# The pydantic BaseModel to help make consistent REST responses - STI 2021-03-05
|
||||
class Resp_Body_Base(BaseModel):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
@@ -19,16 +19,18 @@ class Resp_Body_Base(BaseModel):
|
||||
|
||||
data: Union[dict, list]
|
||||
meta: Optional[dict]
|
||||
# ### END ### API Response Model ### Resp_Body_Base() ###
|
||||
|
||||
|
||||
# The make response function for REST - STI 2021-03-05
|
||||
def mk_resp(data:dict={}, dict_to_json:bool=None, status_code:int=200, status_message:str=None, status_name:str=None, success:bool=True, details:bool=None, by_alias:bool=True, exclude_unset:bool=True):
|
||||
# ### BEGIN ### API Response Model ### mk_resp() ###
|
||||
# The make response function for REST - STI 2021-03-17
|
||||
def mk_resp(data:None|bool|dict|list, dict_to_json:bool=False, status_code:int=200, status_message:str='', status_name:str='', success:bool=True, details:str='', by_alias:bool=True, exclude_unset:bool=True):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if data is None: data = { 'result': None }
|
||||
elif data == False: data = { 'result': False }
|
||||
elif data == True: data = { 'result': True }
|
||||
if data is None: data = { 'result': data }
|
||||
elif data == False: data = { 'result': data }
|
||||
elif data == True: data = { 'result': data }
|
||||
|
||||
resp_body = {}
|
||||
resp_body['data'] = data
|
||||
@@ -54,11 +56,6 @@ def mk_resp(data:dict={}, dict_to_json:bool=None, status_code:int=200, status_me
|
||||
log.debug(type(resp_body['data']))
|
||||
|
||||
resp_body = Resp_Body_Base(**resp_body).dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
#resp_body_json = resp_body.json(by_alias=True, exclude_unset=False)
|
||||
|
||||
#response = app.response_class(
|
||||
#response=resp_body_json,
|
||||
#status=status_code,
|
||||
#mimetype='application/json'
|
||||
#)
|
||||
return resp_body
|
||||
# ### END ### API Response Model ### mk_resp() ###
|
||||
Reference in New Issue
Block a user