Various tweaks for arbitrary model view with "rows"

just needed these for a particular feature...
This commit is contained in:
Lance Edgar 2018-07-26 21:35:15 -05:00
parent 8d77111b06
commit e43f713a66
2 changed files with 11 additions and 9 deletions

View file

@ -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

View file

@ -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):
"""