flush instead of committing inside requests
parent
fe2f1293f1
commit
c6a7051200
|
@ -124,7 +124,7 @@ def gambler_placed_roulette_bet(gambler, bet, which, amount, currency):
|
||||||
{"parent_id": parent_id, "bet": bet, "which": which})
|
{"parent_id": parent_id, "bet": bet, "which": which})
|
||||||
game.active = True
|
game.active = True
|
||||||
db.add(game)
|
db.add(game)
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
|
|
||||||
def get_roulette_bets_and_betters():
|
def get_roulette_bets_and_betters():
|
||||||
|
|
|
@ -283,7 +283,7 @@ def submit_hat(v:User):
|
||||||
|
|
||||||
hat = HatDef(name=name, author_id=author.id, description=description, price=price, submitter_id=v.id)
|
hat = HatDef(name=name, author_id=author.id, description=description, price=price, submitter_id=v.id)
|
||||||
db.add(hat)
|
db.add(hat)
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_HATS']: hats = db.query(HatDef).filter(HatDef.submitter_id != None)
|
if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_HATS']: hats = db.query(HatDef).filter(HatDef.submitter_id != None)
|
||||||
else: hats = db.query(HatDef).filter(HatDef.submitter_id == v.id)
|
else: hats = db.query(HatDef).filter(HatDef.submitter_id == v.id)
|
||||||
|
|
|
@ -40,7 +40,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||||
if notif:
|
if notif:
|
||||||
notif.read = True
|
notif.read = True
|
||||||
db.add(notif)
|
db.add(notif)
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
if comment.parent_submission:
|
if comment.parent_submission:
|
||||||
post = comment.parent_submission
|
post = comment.parent_submission
|
||||||
|
@ -684,5 +684,5 @@ def edit_comment(cid, v):
|
||||||
db.add(c)
|
db.add(c)
|
||||||
|
|
||||||
|
|
||||||
db.commit()
|
db.flush()
|
||||||
return {"body": c.body, "comment": c.realbody(v)}
|
return {"body": c.body, "comment": c.realbody(v)}
|
||||||
|
|
|
@ -328,7 +328,7 @@ def sign_up_post(v:Optional[User]):
|
||||||
|
|
||||||
db.add(new_user)
|
db.add(new_user)
|
||||||
|
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
if ref_id:
|
if ref_id:
|
||||||
ref_user = get_account(ref_id)
|
ref_user = get_account(ref_id)
|
||||||
|
|
|
@ -706,7 +706,7 @@ def submit_post(v:User, sub=None):
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
cache.delete_memoized(userpagelisting)
|
cache.delete_memoized(userpagelisting)
|
||||||
|
|
||||||
db.commit()
|
db.flush()
|
||||||
if v.client: return p.json
|
if v.client: return p.json
|
||||||
else:
|
else:
|
||||||
p.voted = 1
|
p.voted = 1
|
||||||
|
|
|
@ -505,7 +505,7 @@ def settings_security_post(v):
|
||||||
|
|
||||||
v.mfa_secret = None
|
v.mfa_secret = None
|
||||||
db.add(v)
|
db.add(v)
|
||||||
db.commit()
|
db.flush()
|
||||||
return render_template("settings/security.html", v=v, msg="Two-factor authentication disabled!")
|
return render_template("settings/security.html", v=v, msg="Two-factor authentication disabled!")
|
||||||
|
|
||||||
@app.post("/settings/log_out_all_others")
|
@app.post("/settings/log_out_all_others")
|
||||||
|
|
|
@ -817,7 +817,7 @@ def u_username_wall(v:Optional[User], username:str):
|
||||||
if view: view.last_view_utc = int(time.time())
|
if view: view.last_view_utc = int(time.time())
|
||||||
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
|
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
|
||||||
db.add(view)
|
db.add(view)
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
try: page = max(int(request.values.get("page", "1")), 1)
|
try: page = max(int(request.values.get("page", "1")), 1)
|
||||||
except: page = 1
|
except: page = 1
|
||||||
|
@ -872,14 +872,14 @@ def u_username_wall_comment(v:User, username:str, cid):
|
||||||
if view: view.last_view_utc = int(time.time())
|
if view: view.last_view_utc = int(time.time())
|
||||||
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
|
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
|
||||||
db.add(view)
|
db.add(view)
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
if v and request.values.get("read"):
|
if v and request.values.get("read"):
|
||||||
notif = db.query(Notification).filter_by(comment_id=cid, user_id=v.id, read=False).one_or_none()
|
notif = db.query(Notification).filter_by(comment_id=cid, user_id=v.id, read=False).one_or_none()
|
||||||
if notif:
|
if notif:
|
||||||
notif.read = True
|
notif.read = True
|
||||||
db.add(notif)
|
db.add(notif)
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
try: context = min(int(request.values.get("context", 8)), 8)
|
try: context = min(int(request.values.get("context", 8)), 8)
|
||||||
except: context = 8
|
except: context = 8
|
||||||
|
@ -926,7 +926,7 @@ def u_username(v:Optional[User], username:str):
|
||||||
if view: view.last_view_utc = int(time.time())
|
if view: view.last_view_utc = int(time.time())
|
||||||
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
|
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
|
||||||
db.add(view)
|
db.add(view)
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
|
|
||||||
sort = request.values.get("sort", "new")
|
sort = request.values.get("sort", "new")
|
||||||
|
@ -1003,7 +1003,7 @@ def u_username_comments(username, v=None):
|
||||||
if view: view.last_view_utc = int(time.time())
|
if view: view.last_view_utc = int(time.time())
|
||||||
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
|
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
|
||||||
db.add(view)
|
db.add(view)
|
||||||
db.commit()
|
db.flush()
|
||||||
|
|
||||||
try: page = max(int(request.values.get("page", "1")), 1)
|
try: page = max(int(request.values.get("page", "1")), 1)
|
||||||
except: page = 1
|
except: page = 1
|
||||||
|
|
Loading…
Reference in New Issue