Working on event_person and session proposals. Also general clean up of models and methods.

This commit is contained in:
Scott Idem
2021-05-27 23:10:53 -04:00
parent 65fd3ebe28
commit 486236f0a8
10 changed files with 281 additions and 14 deletions

View File

@@ -27,9 +27,15 @@ router = APIRouter()
async def post_event_person_new(
event_person_new: Event_Person_New_Base,
x_account_id: str = Header(...),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
return_obj: bool = True,
inc_event: bool = False,
inc_event_badge: bool = False,
inc_event_person_detail: bool = False,
inc_event_registration: bool = False,
inc_person: bool = False,
inc_user: bool = False,
by_alias: bool = True,
exclude_unset: bool = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -132,7 +138,15 @@ async def post_event_person_new(
return mk_resp(data=False)
elif isinstance(event_person_obj_result, int):
event_person_id = event_person_obj_result
event_person_obj = load_event_person_obj(event_person_id=event_person_id)
event_person_obj = load_event_person_obj(
event_person_id=event_person_id,
inc_event=inc_event,
inc_event_badge=inc_event_badge,
inc_event_person_detail=inc_event_person_detail,
inc_event_registration=inc_event_registration,
inc_person=inc_person,
inc_user=inc_user
)
log.debug(event_person_id)
log.debug(event_person_obj)
else:

View File

@@ -0,0 +1,126 @@
import datetime
#from datetime import datetime, time, timedelta
from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status
from pydantic import BaseModel, EmailStr, Field
from typing import Dict, List, Optional, Set, Union
from ..lib_general import *
from ..log import *
from app.config import settings
from app.db_sql import *
from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
from ..models.event_person_detail_models import Event_Person_Detail_Base
from ..models.response_model import *
router = APIRouter()
@router.post('', response_model=Resp_Body_Base)
async def post_event_person_detail_obj(
obj: Event_Person_Detail_Base,
x_account_id: str = Header(...),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'event_person_detail'
obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
result = post_obj_template(
obj_type=obj_type,
data=obj_data_dict,
return_obj=True,
by_alias=True,
exclude_unset=True,
)
return result
@router.patch('/{obj_id}', response_model=Resp_Body_Base)
async def patch_event_person_detail_obj(
obj: Event_Person_Detail_Base,
obj_id: str = Query(..., min_length=1, max_length=22),
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'event_person_detail'
obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
obj_data_dict['id'] = redis_lookup_id_random(record_id_random=obj_id, table_name=obj_type)
obj_data_dict['id_random'] = obj_id
result = patch_obj_template(
obj_type=obj_type,
data=obj_data_dict,
obj_id=obj_id,
return_obj=True,
by_alias=True,
exclude_unset=True,
)
return result
@router.get('/list', response_model=Resp_Body_Base)
async def get_event_person_detail_obj_li(
for_obj_type: Optional[str] = Query(None, min_length=2, max_length=50),
for_obj_id: Optional[str] = Query(None, min_length=1, max_length=22),
x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'event_person_detail'
result = get_obj_li_template(
obj_type=obj_type,
for_obj_type=for_obj_type,
for_obj_id=for_obj_id,
by_alias=True,
exclude_unset=True,
)
return result
@router.get('/{obj_id}', response_model=Resp_Body_Base)
async def get_event_person_detail_obj(
obj_id: str = Query(..., min_length=1, max_length=22),
x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'event_person_detail'
result = get_obj_template(
obj_type=obj_type,
obj_id=obj_id,
by_alias=True,
exclude_unset=True,
)
return result
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
async def delete_event_person_detail_obj(
obj_id: str = Query(..., min_length=1, max_length=22),
x_account_id: str = Header(...),
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'event_person_detail'
result = delete_obj_template(
obj_type=obj_type,
obj_id=obj_id,
)
return result

View File

@@ -11,7 +11,7 @@ from app.db_sql import *
from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
from ..models.event_session_model import Event_Session_Base
from ..models.event_session_models import Event_Session_Base
from ..models.response_model import *
@@ -43,8 +43,8 @@ async def post_event_session_obj(
@router.patch('/{obj_id}', response_model=Resp_Body_Base)
async def patch_event_session_obj(
obj: Event_Session_Base,
obj_id: str = Query(..., min_length=1, max_length=22),
obj: Event_Session_Base = None,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,