save with commit for default

This commit is contained in:
Cayo Puigdefabregas 2023-03-07 16:41:24 +01:00
parent 7534df083c
commit eed1075771

View file

@ -102,7 +102,7 @@ class UserProfileView(GenericMixin):
self.get_context() self.get_context()
sanitization_form = SanitizationEntityForm() sanitization_form = SanitizationEntityForm()
if g.user.sanitization_entity: if g.user.sanitization_entity:
sanitization = list(g.user.sanitization_entity)[0] sanitization = g.user.sanitization_entity
sanitization_form = SanitizationEntityForm(obj=sanitization) sanitization_form = SanitizationEntityForm(obj=sanitization)
self.context.update( self.context.update(
{ {
@ -138,14 +138,13 @@ class SanitizationEntityView(View):
def dispatch_request(self): def dispatch_request(self):
form = SanitizationEntityForm() form = SanitizationEntityForm()
db.session.commit()
if form.validate_on_submit(): if form.validate_on_submit():
form.save(commit=False) form.save()
messages.success('Sanitization datas updated successfully!') messages.success('Sanitization datas updated successfully!')
else: else:
messages.error('Error modifying Sanitization datas!') messages.error('Error modifying Sanitization datas!')
db.session.commit() # db.session.commit()
return flask.redirect(flask.url_for('core.user-profile')) return flask.redirect(flask.url_for('core.user-profile'))