|
|
|
|
@ -82,7 +82,21 @@ async def rate_picture(session_id: int, picture_id: int, mark: int):
|
|
|
|
|
)
|
|
|
|
|
sessionid = cur.fetchone()
|
|
|
|
|
if sessionid is None:
|
|
|
|
|
return # FIXME[2] # Q: do we return something specific, or just use convention here?
|
|
|
|
|
return {
|
|
|
|
|
"status": "failure" # FIXME[2]
|
|
|
|
|
} # Q: do we return something specific, or just use convention here?
|
|
|
|
|
|
|
|
|
|
# add new mark to the session table
|
|
|
|
|
pass
|
|
|
|
|
try:
|
|
|
|
|
cur.execute(
|
|
|
|
|
"""INSERT INTO marks(imgid, sessionid, mark)
|
|
|
|
|
VALUES(:imgid,:sessionid,:mark)
|
|
|
|
|
""",
|
|
|
|
|
{"imgid": picture_id, "sessionid": sessionid["sessionid"], "mark": mark},
|
|
|
|
|
)
|
|
|
|
|
except sqlite3.IntegrityError as e:
|
|
|
|
|
if str(e) == "UNIQUE constraint failed: marks.imgid, marks.sessionid":
|
|
|
|
|
return {"status": "already rated"}
|
|
|
|
|
|
|
|
|
|
cur.commit()
|
|
|
|
|
return {"status": "success"}
|
|
|
|
|
|