feat: documents backend integration

This commit is contained in:
Timothy J. Baek 2024-01-08 01:49:20 -08:00
parent fe997abc6d
commit eddb6fc7b7
6 changed files with 174 additions and 9 deletions

View file

@ -105,9 +105,10 @@ class DocumentsTable:
).where(Document.name == name)
query.execute()
doc = Document.get(Document.name == name)
doc = Document.get(Document.name == form_data.name)
return DocumentModel(**model_to_dict(doc))
except:
except Exception as e:
print(e)
return None
def delete_doc_by_name(self, name: str) -> bool:

View file

@ -97,8 +97,8 @@ async def update_doc_by_name(
return doc
else:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
status_code=status.HTTP_400_BAD_REQUEST,
detail=ERROR_MESSAGES.NAME_TAG_TAKEN,
)

View file

@ -18,6 +18,7 @@ class ERROR_MESSAGES(str, Enum):
"Uh-oh! This username is already registered. Please choose another username."
)
COMMAND_TAKEN = "Uh-oh! This command is already registered. Please choose another command string."
NAME_TAG_TAKEN = "Uh-oh! This name tag is already registered. Please choose another name tag string."
INVALID_TOKEN = (
"Your session has expired or the token is invalid. Please sign in again."
)