|
@ -92,6 +92,8 @@ def put_topic_vote(request: Request) -> Response: |
|
|
new_vote = TopicVote(request.user, topic) |
|
|
new_vote = TopicVote(request.user, topic) |
|
|
request.db_session.add(new_vote) |
|
|
request.db_session.add(new_vote) |
|
|
|
|
|
|
|
|
|
|
|
request.db_session.add(LogTopic(LogEventType.TOPIC_VOTE, request, topic)) |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
# manually flush before attempting to commit, to avoid having all objects |
|
|
# manually flush before attempting to commit, to avoid having all objects |
|
|
# detached from the session in case of an error |
|
|
# detached from the session in case of an error |
|
@ -126,6 +128,8 @@ def delete_topic_vote(request: Request) -> Response: |
|
|
TopicVote.topic == topic, TopicVote.user == request.user |
|
|
TopicVote.topic == topic, TopicVote.user == request.user |
|
|
).delete(synchronize_session=False) |
|
|
).delete(synchronize_session=False) |
|
|
|
|
|
|
|
|
|
|
|
request.db_session.add(LogTopic(LogEventType.TOPIC_UNVOTE, request, topic)) |
|
|
|
|
|
|
|
|
# manually commit the transaction so triggers will execute |
|
|
# manually commit the transaction so triggers will execute |
|
|
request.tm.commit() |
|
|
request.tm.commit() |
|
|
|
|
|
|
|
|