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

@@ -343,7 +343,8 @@ origins = [
'http://demo.localhost:5000',
'http://localhost:7800',
'https://oneskyit.com',
'http://dev-idaa.localhost:5000'
'http://dev-idaa.localhost:5000',
'http://connect.home:5000',
]
app.add_middleware(

View File

@@ -103,7 +103,7 @@ def update_contact_obj(
contact_obj_up: Contact_Base,
create_missing_obj: bool = False,
) -> 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 contact_id := redis_lookup_id_random(record_id_random=contact_id, table_name='contact'): pass

View File

@@ -106,22 +106,22 @@ def load_event_person_obj(
if inc_event_track_list: pass
if inc_person:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if person_obj := load_person_obj(
inc_address=inc_address,
inc_contact=inc_contact,
person_id=person_id
):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(person_obj)
event_person_obj.person = person_obj.dict(by_alias=True, exclude_unset=True)
else:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug('A person object was not returned.')
event_person_obj.person = None
if inc_user:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if user_obj := load_user_obj(user_id=user_id):
log.debug(user_obj)
event_person_obj.user = user_obj.dict(by_alias=True, exclude_unset=True)
@@ -138,7 +138,7 @@ def update_event_person_obj(
event_person_obj_up: Event_Person_Base,
create_missing_obj: bool = False,
) -> 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 event_person_id := redis_lookup_id_random(record_id_random=event_person_id, table_name='event_person'): pass
@@ -179,7 +179,7 @@ def update_event_person_obj(
return False
if event_person_obj_up.user_id and event_person_obj_up.user:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
user_id = event_person_obj_up.user_id
user_obj_up = event_person_obj_up.user
log.debug(user_id)

View File

@@ -46,7 +46,7 @@ def load_event_presentation_obj(
else: return False
if event_presentation_rec := sql_select(table_name='v_event_presentation', record_id=event_presentation_id):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_presentation_rec)
try:
@@ -74,7 +74,7 @@ def load_event_presentation_obj(
if inc_event_file_list: pass
if inc_event_person_list: pass
if inc_event_presenter_list:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
data = {}
data['event_presentation_id'] = event_presentation_id
@@ -106,7 +106,7 @@ def load_event_presentation_obj(
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if event_presenter_obj_li_result := sql_select(data=data, sql=sql, as_list=True):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_presenter_obj_li_result)
event_presenter_obj_li = []
for event_presenter_obj in event_presenter_obj_li_result:
@@ -147,7 +147,7 @@ def update_event_presentation_obj(
event_presentation_obj_up: Event_Presentation_Base,
create_missing_obj: bool = False,
) -> 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 event_presentation_id := redis_lookup_id_random(record_id_random=event_presentation_id, table_name='event_presentation'): pass

View File

@@ -35,14 +35,14 @@ def load_event_presenter_obj(
inc_person: bool = False, # Using load_event_person_obj
inc_user: bool = False, # Using load_event_person_obj
) -> Event_Presenter_Base|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 event_presenter_id := redis_lookup_id_random(record_id_random=event_presenter_id, table_name='event_presenter'): pass
else: return False
if event_presenter_rec := sql_select(table_name='v_event_presenter', record_id=event_presenter_id):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_presenter_rec)
try:
@@ -70,7 +70,7 @@ def load_event_presenter_obj(
if inc_event_file_list: pass
if inc_event_person:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if event_person_obj := load_event_person_obj(
event_person_id=event_person_id,
@@ -117,7 +117,7 @@ def update_event_presenter_obj(
event_presenter_obj_up: Event_Presenter_Base,
create_missing_obj: bool = False,
) -> 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 event_presenter_id := redis_lookup_id_random(record_id_random=event_presenter_id, table_name='event_presenter'): pass
@@ -131,7 +131,7 @@ def update_event_presenter_obj(
# log.debug(event_presenter_obj_up.dict(by_alias=False, exclude_unset=False))
if event_presenter_obj_up.event_person_id and event_presenter_obj_up.event_person:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
event_person_id = event_presenter_obj_up.event_person_id
event_person_obj_up = event_presenter_obj_up.event_person
log.debug(event_person_id)

View File

@@ -99,7 +99,7 @@ def load_event_session_obj(
if inc_event_person_list: pass
if inc_event_presentation_list:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
data = {}
data['event_session_id'] = event_session_id
@@ -126,7 +126,7 @@ def load_event_session_obj(
FROM `event_presentation` AS `event_presentation`
WHERE `event_presentation`.event_session_id = :event_session_id
{sql_enabled}
ORDER BY `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC;
ORDER BY `event_presentation`.priority DESC, `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC;
"""
#log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
@@ -204,7 +204,7 @@ def update_event_session_obj(
event_session_obj_up: Event_Session_Base,
create_missing_obj: bool = False,
) -> 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 event_session_id := redis_lookup_id_random(record_id_random=event_session_id, table_name='event_session'): pass
@@ -246,7 +246,7 @@ def update_event_session_obj(
return False
if event_session_obj_up.event_presentation_id and event_session_obj_up.event_presentation:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
event_presentation_id = event_session_obj_up.event_presentation_id
event_presentation_obj_up = event_session_obj_up.event_presentation
log.debug(event_presentation_id)

View File

@@ -12,7 +12,7 @@ from app.models.common_field_schema import base_fields, default_num_bytes
class Address_Base(BaseModel):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
id_random: Optional[str] = Field(

View File

@@ -51,7 +51,7 @@ class Event_File_Base(BaseModel):
title: Optional[str]
description: Optional[str]
lu_file_purpose_id: Optional[str]
lu_file_purpose_id: Optional[int]
file_purpose: Optional[str]
enable: Optional[bool]

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