Merge branch 'v1_db_schema' into main

This commit is contained in:
Andreas Köpf
2022-12-16 09:48:06 +01:00
15 changed files with 498 additions and 36 deletions
+6 -6
View File
@@ -21,7 +21,7 @@ def read_labelers(
"""
Retrieve labelers.
"""
deps.api_auth(api_key, db, read=True)
deps.api_auth(api_key, db)
if limit > 10000:
raise HTTPException(status_code=HTTP_400_BAD_REQUEST, detail="Bad request")
labelers = crud.labeler.get_multi(db, begin_id=begin_id, limit=limit)
@@ -38,7 +38,7 @@ def create_labeler(
"""
Create new labeler.
"""
deps.api_auth(api_key, db, create=True)
deps.api_auth(api_key, db)
item = crud.labeler.create(db=db, obj_in=item_in)
return item
@@ -54,7 +54,7 @@ def update_labeler(
"""
Update a labeler.
"""
deps.api_auth(api_key, db, update=True, read=True)
deps.api_auth(api_key, db)
item = crud.labeler.get(db=db, id=id)
if not item:
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="Item not found")
@@ -72,7 +72,7 @@ def read_labeler_by_username(
"""
Get labeler by ID.
"""
deps.api_auth(api_key, db, read=True)
deps.api_auth(api_key, db)
item = crud.labeler.get_by_discord_username(db=db, discord_username=discord_username)
if not item:
raise HTTPException(status_code=404, detail="Item not found")
@@ -89,7 +89,7 @@ def read_labeler(
"""
Get labeler by ID.
"""
deps.api_auth(api_key, db, read=True)
deps.api_auth(api_key, db)
item = crud.labeler.get(db=db, id=id)
if not item:
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="Item not found")
@@ -106,7 +106,7 @@ def delete_labeler(
"""
Delete a labeler.
"""
deps.api_auth(api_key, db, delete=True)
deps.api_auth(api_key, db)
labeler = crud.labeler.get(db=db, id=id)
if not labeler:
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="Item not found")
+4 -4
View File
@@ -21,7 +21,7 @@ def read_prompts(
"""
Retrieve prompts.
"""
deps.api_auth(api_key, db, read=True)
deps.api_auth(api_key, db)
if limit > 10000:
raise HTTPException(status_code=HTTP_400_BAD_REQUEST, detail="Bad request")
return crud.prompt.get_multi(db, begin_id=begin_id, limit=limit)
@@ -37,7 +37,7 @@ def create_prompt(
"""
Create new prompt.
"""
deps.api_auth(api_key, db, create=True)
deps.api_auth(api_key, db)
if item_in.labeler_id is None:
if item_in.discord_username is None:
raise HTTPException(status_code=HTTP_400_BAD_REQUEST, detail="Bad request")
@@ -66,7 +66,7 @@ def read_prompt(
"""
Get prompt by ID.
"""
deps.api_auth(api_key, db, read=True)
deps.api_auth(api_key, db)
item = crud.prompt.get(db=db, id=id)
if not item:
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="Item not found")
@@ -83,7 +83,7 @@ def delete_prompt(
"""
Delete a prompt.
"""
deps.api_auth(api_key, db, delete=True)
deps.api_auth(api_key, db)
item = crud.prompt.get(db=db, id=id)
if not item:
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="Item not found")
+3 -3
View File
@@ -55,7 +55,7 @@ def request_task(
"""
Create new task.
"""
deps.api_auth(api_key, db, create=True)
deps.api_auth(api_key, db)
try:
task = generate_task(request)
@@ -79,7 +79,7 @@ def acknowledge_task(
"""
The frontend acknowledges a task.
"""
deps.api_auth(api_key, db, create=True)
deps.api_auth(api_key, db)
match (type(response)):
case protocol_schema.PostCreatedTaskResponse:
@@ -107,7 +107,7 @@ def post_interaction(
"""
The frontend reports an interaction.
"""
deps.api_auth(api_key, db, create=True)
deps.api_auth(api_key, db)
match (type(interaction)):
case protocol_schema.TextReplyToPost: