Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Commit

Permalink
Switch to manual transaction management when voting on talks
Browse files Browse the repository at this point in the history
Seems the automatic one works fine in dev, but not in production,
probably django version mismatch. Trying again with explicit manual
transaction management.
  • Loading branch information
mhagander committed Apr 14, 2012
1 parent c124d85 commit fa2f471
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions postgresqleu/confreg/views.py
Expand Up @@ -667,7 +667,6 @@ def __init__(self, session, n):




@login_required @login_required
@transaction.commit_on_success
def talkvote(request, confname): def talkvote(request, confname):
if settings.FORCE_SECURE_FORMS and not request.is_secure(): if settings.FORCE_SECURE_FORMS and not request.is_secure():
return HttpResponseRedirect(request.build_absolute_uri().replace('http://','https://',1)) return HttpResponseRedirect(request.build_absolute_uri().replace('http://','https://',1))
Expand All @@ -683,19 +682,21 @@ def talkvote(request, confname):
# this code won't run often, so we don't really care about being # this code won't run often, so we don't really care about being
# fast, and this is easier... # fast, and this is easier...
# Thus, remove existing entries and replace them with current ones. # Thus, remove existing entries and replace them with current ones.
curs.execute("DELETE FROM confreg_conferencesessionvote WHERE voter_id=%(userid)s AND session_id IN (SELECT id FROM confreg_conferencesession WHERE conference_id=%(confid)s)", { with transaction.commit_manually():
'confid': conference.id, curs.execute("DELETE FROM confreg_conferencesessionvote WHERE voter_id=%(userid)s AND session_id IN (SELECT id FROM confreg_conferencesession WHERE conference_id=%(confid)s)", {
'userid': request.user.id, 'confid': conference.id,
}) 'userid': request.user.id,
curs.executemany("INSERT INTO confreg_conferencesessionvote (session_id, voter_id, vote, comment) VALUES (%(sid)s, %(vid)s, %(vote)s, %(comment)s)", [ })
{ curs.executemany("INSERT INTO confreg_conferencesessionvote (session_id, voter_id, vote, comment) VALUES (%(sid)s, %(vid)s, %(vote)s, %(comment)s)", [
'sid': k[3:], {
'vid': request.user.id, 'sid': k[3:],
'vote': int(v) > 0 and int(v) or None, 'vid': request.user.id,
'comment': request.POST['tc_%s' % k[3:]], 'vote': int(v) > 0 and int(v) or None,
} 'comment': request.POST['tc_%s' % k[3:]],
for k,v in request.POST.items() if k.startswith("sv_") and (int(v)>0 or request.POST['tc_%s' % k[3:]]) }
]) for k,v in request.POST.items() if k.startswith("sv_") and (int(v)>0 or request.POST['tc_%s' % k[3:]])
])
transaction.commit()
return HttpResponseRedirect(".") return HttpResponseRedirect(".")


order = "" order = ""
Expand Down

0 comments on commit fa2f471

Please sign in to comment.