Skip to content

Commit

Permalink
Better support for before callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 22, 2020
1 parent 61613ac commit d90c7f1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/appier_extras/parts/admin/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,11 @@ def post_delete(self):

def save_v(self, *args, **kwargs):
is_new = kwargs.get("is_new", None)
before_callbacks = kwargs.get("before_callbacks", [])
if is_new == None: is_new = self.is_new()
self.__class__.ensure_views(self.model, ensure_set = is_new)
ensure_callback = lambda instance, model: self.__class__.ensure_views(model)
before_callbacks.append(ensure_callback)
kwargs["before_callbacks"] = before_callbacks
appier.Model.save(self, *args, **kwargs)

def previous(self, name = "id", raise_e = False, *args, **kwargs):
Expand Down

0 comments on commit d90c7f1

Please sign in to comment.