From e43f713a664de00b7b4371f5b40a90d9a276ebd1 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 26 Jul 2018 21:35:15 -0500 Subject: [PATCH] Various tweaks for arbitrary model view with "rows" just needed these for a particular feature... --- tailbone/forms/core.py | 4 ++-- tailbone/views/master.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tailbone/forms/core.py b/tailbone/forms/core.py index 0f7211c4..e9c33b11 100644 --- a/tailbone/forms/core.py +++ b/tailbone/forms/core.py @@ -839,9 +839,9 @@ class Form(object): else: # legacy behavior raise_error = kwargs.pop('raise_error', True) - form = self.make_deform_form() + dform = self.make_deform_form() try: - return form.validate(*args, **kwargs) + return dform.validate(*args, **kwargs) except deform.ValidationFailure: if raise_error: raise diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 84ea376d..01e48776 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -1343,6 +1343,8 @@ class MasterView(View): @classmethod def get_row_model_title_plural(cls): + if hasattr(cls, 'row_model_title_plural'): + return cls.row_model_title_plural return "{} Rows".format(cls.get_model_title()) def view_index(self): @@ -2395,7 +2397,9 @@ class MasterView(View): return True return False - def objectify(self, form, data): + def objectify(self, form, data=None): + if data is None: + data = form.validated obj = form.schema.objectify(data, context=form.model_instance) return obj @@ -2822,12 +2826,10 @@ class MasterView(View): self.set_row_labels(form) def validate_row_form(self, form): - controls = self.request.POST.items() - try: - self.form_deserialized = form.validate(controls) - except deform.ValidationFailure: - return False - return True + if form.validate(newstyle=True): + self.form_deserialized = form.validated + return True + return False def get_row_action_url(self, action, row, mobile=False): """