Ensure preferences are properly saved the first time they're set.

This commit is contained in:
Akshay Joshi 2017-03-27 12:19:28 -04:00 committed by Dave Page
parent b2ab35e990
commit 757500c478

View File

@ -197,13 +197,14 @@ class _Preference(object):
pid=self.pid
).filter_by(uid=current_user.id).first()
value = u"{}".format(value)
if pref is None:
pref = UserPrefTable(
uid=current_user.id, pid=self.pid, value=value
)
db.session.add(pref)
else:
pref.value = u"{}".format(value)
pref.value = value
db.session.commit()
return True, None