1. Simone Marzola
  2. tgapp-tgcomments


Simone Marzola  committed 3c94e68

catch IntegrityErrors in votes and rollback the transaction

  • Participants
  • Parent commits 5f59c2e
  • Branches default

Comments (0)

Files changed (1)

File tgcomments/controllers/root.py

View file
 def back_to_referer(*args, **kw):
     if not kw.get('success'):
-        flash('Failed to post comment', 'error')
+        flash(_('Failed to post comment'), 'error')
     if request.referer is not None:
         raise redirect(request.referer)
     raise redirect(request.host_url)
-            transaction.commit()
         except IntegrityError:
-            return back_to_referer(success=False)
+            transaction.doom()
+            flash(_('Already voted this comment'), 'warning')
+            return back_to_referer(success=True)
         flash(_('Thanks for your vote!'))
         return back_to_referer(success=True)