Commit 5ef6c7f7 authored by Sean Lynch's avatar Sean Lynch

Allow making model changing in on_model_change before persisiting when using peewee

parent 9388b78c
......@@ -277,13 +277,12 @@ class ModelView(BaseModelView):
try:
model = self.model()
form.populate_obj(model)
self.on_model_change(form, model)
model.save()
# For peewee have to save inline forms after model was saved
save_inline(form, model)
self.on_model_change(form, model)
return True
except Exception, ex:
flash(gettext('Failed to create model. %(error)s', error=str(ex)), 'error')
......@@ -292,13 +291,12 @@ class ModelView(BaseModelView):
def update_model(self, form, model):
try:
form.populate_obj(model)
self.on_model_change(form, model)
model.save()
# For peewee have to save inline forms after model was saved
save_inline(form, model)
self.on_model_change(form, model)
return True
except Exception, ex:
flash(gettext('Failed to update model. %(error)s', error=str(ex)), 'error')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment