Work on file uploads and session proposals

This commit is contained in:
Scott Idem
2021-06-16 15:08:05 -04:00
parent 0dc50e4509
commit e9399e107f
13 changed files with 93 additions and 43 deletions

View File

@@ -44,29 +44,26 @@ async def post_address_obj(
return result
@router.patch('/{obj_id}', response_model=Resp_Body_Base)
@router.patch('/{address_obj_id}', response_model=Resp_Body_Base)
async def patch_address_obj(
obj: Address_Base,
obj_id: str = Query(..., min_length=1, max_length=22),
address_obj: Address_Base,
address_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,
include: Optional[list] = [],
exclude: Optional[list] = [],
exclude_unset: Optional[bool] = True,
exclude_none: Optional[bool] = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'address'
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
address_obj_type = 'address'
address_obj_data_dict = address_obj.dict(by_alias=False, exclude_unset=True)
address_obj_data_dict['id'] = redis_lookup_id_random(record_id_random=address_obj_id, table_name=address_obj_type)
address_obj_data_dict['id_random'] = address_obj_id
result = patch_obj_template(
obj_type=obj_type,
data=obj_data_dict,
obj_id=obj_id,
obj_type=address_obj_type,
data=address_obj_data_dict,
obj_id=address_obj_id,
return_obj=True,
by_alias=True,
exclude_unset=True,

View File

@@ -38,4 +38,47 @@ async def post_event_file_obj(
by_alias=True,
exclude_unset=True,
)
return result
@router.patch('/{obj_id}', response_model=Resp_Body_Base)
async def patch_event_file_obj(
obj: Event_File_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.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'event_file'
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.delete('/{obj_id}', response_model=Resp_Body_Base)
async def delete_event_file_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_file'
result = delete_obj_template(
obj_type=obj_type,
obj_id=obj_id,
)
return result

View File

@@ -1,4 +1,4 @@
import datetime
import datetime, secrets
from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status
from pydantic import BaseModel, EmailStr, Field
from typing import Dict, List, Optional, Set, Union
@@ -14,6 +14,7 @@ from app.methods.person_methods import create_person_obj, load_person_obj
from app.methods.user_methods import create_user_obj, load_user_obj, update_user_obj
# from app.methods.user_load_methods import load_user_obj
from app.models.common_field_schema import default_num_bytes
from app.models.event_person_models import Event_Person_New_Base, Event_Person_Base
from app.models.person_models import Person_Base
from app.models.response_models import Resp_Body_Base, mk_resp

View File

@@ -5,14 +5,14 @@ from typing import Dict, List, Optional, Set, Union
from app.lib_general import log, logging
from app.config import settings
from app.db_sql import *
from app.db_sql import sql_insert, sql_update, sql_insert_or_update, sql_select, sql_delete, redis_lookup_id_random
from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
from app.methods.event_presenter_methods import load_event_presenter_obj, update_event_presenter_obj
from app.models.event_presenter_models import Event_Presenter_Base
from app.models.response_models import *
from app.models.response_models import Resp_Body_Base, mk_resp
router = APIRouter()

View File

@@ -1,4 +1,4 @@
import datetime
import datetime, json
from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status
from pydantic import BaseModel, EmailStr, Field
from typing import Dict, List, Optional, Set, Union
@@ -50,11 +50,19 @@ async def patch_event_session_obj(
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'event_session'
obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
log.debug(obj_data_dict)
log.debug(type(obj_data_dict['proposal_json']))
if 'proposal_json' in obj_data_dict and isinstance(obj_data_dict['proposal_json'], dict):
log.debug('Need to convert to JSON string')
obj_data_dict['proposal_json'] = json.dumps(obj_data_dict['proposal_json'])
log.debug(obj_data_dict)
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(
@@ -273,7 +281,7 @@ async def get_event_session_obj(
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if event_session_id := redis_lookup_id_random(record_id_random=event_session_id, table_name='event_session'): pass