Work on event launcher and related

This commit is contained in:
Scott Idem
2021-10-22 04:07:41 -04:00
parent bde6ec1a2b
commit 661e9ca417
10 changed files with 53 additions and 23 deletions

View File

@@ -37,7 +37,6 @@ def create_event_file_obj(event_file_obj_new:Event_File_Base):
# ### BEGIN ### API Event File Methods ### load_event_file_obj() ###
def load_event_file_obj(
event_file_id: int|str,
limit: int = 100,
model_as_dict: bool = True,
by_alias: bool = True,
exclude_unset: bool = False,
@@ -91,7 +90,6 @@ def load_event_file_obj(
# model_as_dict = True
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if model_as_dict:
log.debug(event_file_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)) # pylint: disable=no-member)
return event_file_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
@@ -262,7 +260,6 @@ def load_event_file_obj_list(
event_file_id = event_file_rec.get('event_file_id', None)
if event_file_result := load_event_file_obj(
event_file_id = event_file_id,
limit = limit,
model_as_dict = True, # NOTE: This is overriding the model_as_dict param!
enabled = enabled,
inc_hosted_file = inc_hosted_file,

View File

@@ -84,7 +84,6 @@ def load_event_location_obj(
if load_event_file_result := load_event_file_obj(
event_file_id = event_file_rec.get('event_file_id', None),
enabled = enabled,
limit = limit,
# inc_hosted_file = inc_hosted_file,
# model_as_dict = True,
# by_alias = by_alias,

View File

@@ -195,7 +195,6 @@ def load_event_obj(
if load_event_file_result := load_event_file_obj(
event_file_id = event_file_rec.get('event_file_id', None),
enabled = enabled,
limit = limit,
# inc_hosted_file = inc_hosted_file,
# model_as_dict = True,
# by_alias = by_alias,

View File

@@ -256,7 +256,7 @@ def get_event_presentation_rec_list(
{sql_where_event_session_id}
{sql_hidden}
{sql_enabled}
ORDER BY `event_presentation`.start_datetime ASC, `event_presentation`.sort ASC, `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC
ORDER BY `event_presentation`.start_datetime ASC, `event_presentation`.sort ASC, `event_presentation`.name ASC, `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC
{sql_limit};
"""

View File

@@ -105,7 +105,6 @@ def load_event_presenter_obj(
if load_event_file_result := load_event_file_obj(
event_file_id = event_file_rec.get('event_file_id', None),
enabled = enabled,
limit = limit,
# inc_hosted_file = inc_hosted_file,
# by_alias = by_alias,
# exclude_unset = exclude_unset,

View File

@@ -111,7 +111,6 @@ def load_event_session_obj(
if load_event_file_result := load_event_file_obj(
event_file_id = event_file_rec.get('event_file_id', None),
enabled = enabled,
limit = limit,
inc_hosted_file = inc_hosted_file,
# model_as_dict = True,
# by_alias = by_alias,
@@ -353,7 +352,7 @@ def get_event_session_rec_list(
{sql_approved}
{sql_hidden}
{sql_enabled}
ORDER BY `event_session`.created_on DESC, `event_session`.updated_on DESC
ORDER BY `event_session`.start_datetime ASC, `event_session`.sort ASC, `event_session`.name ASC, `event_session`.created_on DESC, `event_session`.updated_on DESC
{sql_limit};
"""

View File

@@ -79,6 +79,9 @@ class Event_File_Base(BaseModel):
# Including convenience data
# This is only for convenience. Probably going to keep unless it causes a problem.
hosted_file_hash_sha256: Optional[str] = Field(
alias = 'hash_sha256'
)
hosted_file_size: Optional[str] = Field(
alias = 'file_size'
)

View File

@@ -126,6 +126,42 @@ async def event_file_lookup(
# ### END ### API Event File ### get_event_file_lookup() ###
# ### BEGIN ### API Event File ### get_event_file_obj() ###
# Updated 2021-10-21
@router.get('/{event_file_id}', response_model=Resp_Body_Base)
async def get_event_file_obj(
event_file_id: str = Query(..., min_length=11, max_length=22),
inc_hosted_file: bool = False,
enabled: str = 'enabled', # enabled, disabled, all; For now this covers any included objects or object lists
hidden: str = 'not_hidden', # hidden, not_hidden, all
x_account_id: str = Header(...),
by_alias: bool = True,
exclude_unset: bool = True,
response: Response = Response,
):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if event_file_id := redis_lookup_id_random(record_id_random=event_file_id, table_name='event_file'): pass
else: return mk_resp(data=None, status_code=404, response=response)
if event_file_obj := load_event_file_obj(
event_file_id = event_file_id,
enabled = enabled,
# hidden = hidden,
inc_hosted_file = inc_hosted_file,
model_as_dict = False,
):
event_file_dict = event_file_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
pass
else:
return mk_resp(data=False, status_code=400, response=response) # Bad Request
return mk_resp(data=event_file_dict, response=response)
#return mk_resp(data=event_file_obj)
# ### END ### API Event File ### get_event_file_obj() ###
@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),

View File

@@ -90,7 +90,7 @@ async def patch_event_presentation_json(
if event_presentation_id := redis_lookup_id_random(record_id_random=event_presentation_id, table_name='event_presentation'): pass
else:
return mk_resp(data=None, status_code=404)
return mk_resp(data=None, status_code=404, response=response)
if event_presentation_obj_up_result := update_event_presentation_obj(
event_presentation_id=event_presentation_id,
@@ -102,9 +102,9 @@ async def patch_event_presentation_json(
if return_obj:
event_presentation_obj = load_event_presentation_obj(event_presentation_id=event_presentation_id)
event_presentation_dict = event_presentation_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
return mk_resp(data=event_presentation_dict)
return mk_resp(data=event_presentation_dict, response=response)
else:
return mk_resp(data=event_presentation_obj_up_result)
return mk_resp(data=event_presentation_obj_up_result, response=response)
else:
return mk_resp(data=False, status_code=400, response=response) # Bad Request
# ### END ### API Event Presentation ### patch_event_presentation_json() ###
@@ -145,7 +145,7 @@ async def get_event_presentation_obj(
if event_presentation_id := redis_lookup_id_random(record_id_random=event_presentation_id, table_name='event_presentation'): pass
else:
return mk_resp(data=None, status_code=404)
return mk_resp(data=None, status_code=404, response=response)
if event_presentation_obj := load_event_presentation_obj(
event_presentation_id = event_presentation_id,
@@ -174,7 +174,7 @@ async def get_event_presentation_obj(
else:
return mk_resp(data=False, status_code=400, response=response) # Bad Request
return mk_resp(data=event_presentation_dict)
return mk_resp(data=event_presentation_dict, response=response)
#return mk_resp(data=event_presentation_obj)
# ### END ### API Event Presentation ### get_event_presentation_obj() ###

View File

@@ -89,8 +89,7 @@ async def patch_event_presenter_json(
log.debug(locals())
if event_presenter_id := redis_lookup_id_random(record_id_random=event_presenter_id, table_name='event_presenter'): pass
else:
return mk_resp(data=None, status_code=404)
else: return mk_resp(data=None, status_code=404, response=response)
if event_presenter_obj_up_result := update_event_presenter_obj(
event_presenter_id=event_presenter_id,
@@ -102,9 +101,9 @@ async def patch_event_presenter_json(
if return_obj:
event_presenter_obj = load_event_presenter_obj(event_presenter_id=event_presenter_id)
event_presenter_dict = event_presenter_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
return mk_resp(data=event_presenter_dict)
return mk_resp(data=event_presenter_dict, response=response)
else:
return mk_resp(data=event_presenter_obj_up_result)
return mk_resp(data=event_presenter_obj_up_result, response=response)
else:
return mk_resp(data=False, status_code=400, response=response) # Bad Request
# ### END ### API Event Presenter ### patch_event_presenter_json() ###
@@ -204,7 +203,7 @@ async def get_event_presenter_obj_li(
):
data = event_presenter_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
event_presenter_li.append(data)
return mk_resp(data=event_presenter_li)
return mk_resp(data=event_presenter_li, response=response)
else:
log.debug(event_presenter_li_result)
return mk_resp(data=False, status_code=404, response=response)
@@ -264,8 +263,7 @@ async def get_event_presenter_obj(
log.debug(locals())
if event_presenter_id := redis_lookup_id_random(record_id_random=event_presenter_id, table_name='event_presenter'): pass
else:
return mk_resp(data=None, status_code=404)
else: return mk_resp(data=None, status_code=404, response=response)
if event_presenter_obj := load_event_presenter_obj(
event_presenter_id = event_presenter_id,
@@ -292,8 +290,8 @@ async def get_event_presenter_obj(
else:
return mk_resp(data=False, status_code=400, response=response) # Bad Request
return mk_resp(data=event_presenter_dict)
#return mk_resp(data=event_presenter_obj)
return mk_resp(data=event_presenter_dict, response=response)
#return mk_resp(data=event_presenter_obj, response=response)
# ### END ### API Event Presenter ### get_event_presenter_obj() ###