Work on event files and hosted files
This commit is contained in:
@@ -89,7 +89,6 @@ def load_event_session_obj(
|
||||
if inc_event_abstract_list: pass
|
||||
if inc_event_badge_list: pass
|
||||
if inc_event_device_list: pass
|
||||
if inc_event_file_list: pass
|
||||
|
||||
if inc_event_file_list:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
|
||||
@@ -82,6 +82,12 @@ class Event_File_Base(BaseModel):
|
||||
hosted_file_hash_sha256: Optional[str] = Field(
|
||||
alias = 'hash_sha256'
|
||||
)
|
||||
hosted_file_subdirectory_path: Optional[str] = Field( # NOTE: This will frequently only contain numbers, but it still needs to be a string
|
||||
alias = 'subdirectory_path'
|
||||
)
|
||||
hosted_file_content_type: Optional[str] = Field(
|
||||
alias = 'content_type'
|
||||
)
|
||||
hosted_file_size: Optional[str] = Field(
|
||||
alias = 'file_size'
|
||||
)
|
||||
|
||||
@@ -162,18 +162,46 @@ async def get_event_file_obj(
|
||||
# ### END ### API Event File ### get_event_file_obj() ###
|
||||
|
||||
|
||||
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
||||
@router.delete('/{event_file_id}', response_model=Resp_Body_Base)
|
||||
async def delete_event_file_obj(
|
||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
||||
event_file_id: str = Query(..., min_length=11, max_length=22),
|
||||
hosted_file_id: str = Query(..., min_length=11, max_length=22),
|
||||
for_type: str = Query(..., min_length=1, max_length=25),
|
||||
for_id: str = Query(..., min_length=11, max_length=22),
|
||||
delete_hosted_file: bool = False,
|
||||
x_account_id: str = Header(...),
|
||||
response: Response = Response,
|
||||
):
|
||||
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_file'
|
||||
result = delete_obj_template(
|
||||
obj_type=obj_type,
|
||||
obj_id=obj_id,
|
||||
)
|
||||
return result
|
||||
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 hosted_file_id := redis_lookup_id_random(record_id_random=hosted_file_id, table_name='hosted_file'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=response)
|
||||
|
||||
if for_id := redis_lookup_id_random(record_id_random=for_id, table_name=for_type): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=response)
|
||||
|
||||
if event_file_delete_result := sql_delete(table_name='event_file', record_id=event_file_id):
|
||||
log.info(f'Deleted Event File ID: {event_file_id}')
|
||||
else: return mk_resp(data=False, status_code=500, response=response) # Internal Server Error
|
||||
|
||||
sql = f"""
|
||||
DELETE FROM hosted_file_link
|
||||
WHERE hosted_file_id = :hosted_file_id
|
||||
AND link_to_type = :for_type
|
||||
AND link_to_id = :for_id
|
||||
"""
|
||||
hosted_file_link_data = {}
|
||||
hosted_file_link_data['hosted_file_id'] = hosted_file_id
|
||||
hosted_file_link_data['for_type'] = for_type
|
||||
hosted_file_link_data['for_id']
|
||||
log.debug(hosted_file_link_data)
|
||||
|
||||
if event_file_delete_result := sql_delete(sql=sql, data=hosted_file_link_data):
|
||||
log.info(f'Deleted Hosted File Link. Hosted File ID: {hosted_file_id}, Link To Type: {for_type}, Link To ID: {for_id}')
|
||||
else: return mk_resp(data=False, status_code=500, response=response) # Internal Server Error
|
||||
|
||||
return mk_resp(data=True, response=response)
|
||||
|
||||
Reference in New Issue
Block a user