Skip to content
Snippets Groups Projects
Commit bf2878f0 authored by Tomáš Hozman's avatar Tomáš Hozman
Browse files

allow deleting + previous work and pirati.cz @23m

parent 2a7dfb11
Branches
No related tags found
No related merge requests found
......@@ -45,6 +45,34 @@ def add_vote() -> typing.Union[flask.Response, int]:
return flask.jsonify(None), http.client.NO_CONTENT
@measurer_blueprint.route("/", methods=["DELETE"])
@validators.validate_json({
"point": {
"type": "string",
"allowed": flask.current_app.config["POINTS"],
"nullable": False
}
})
def delete_vote() -> typing.Union[flask.Response, int]:
vote = flask.g.sa_session.execute(
sqlalchemy.select(database.Vote).
where(
sqlalchemy.and_(
database.Vote.point == flask.g.json["point"],
database.Vote.identifier == utils.get_ip_hash()
)
)
).scalars().one_or_none()
if vote is None:
raise werkzeug.exceptions.NotFound
flask.g.sa_session.delete(vote)
flask.g.sa_session.commit()
return flask.jsonify(None), http.client.NO_CONTENT
@measurer_blueprint.route("/", methods=["GET"])
def list_votes() -> typing.Union[flask.Response, int]:
votes = flask.g.sa_session.execute(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment