Various tweaks for arbitrary model view with "rows"
just needed these for a particular feature...
This commit is contained in:
parent
8d77111b06
commit
e43f713a66
|
@ -839,9 +839,9 @@ class Form(object):
|
||||||
|
|
||||||
else: # legacy behavior
|
else: # legacy behavior
|
||||||
raise_error = kwargs.pop('raise_error', True)
|
raise_error = kwargs.pop('raise_error', True)
|
||||||
form = self.make_deform_form()
|
dform = self.make_deform_form()
|
||||||
try:
|
try:
|
||||||
return form.validate(*args, **kwargs)
|
return dform.validate(*args, **kwargs)
|
||||||
except deform.ValidationFailure:
|
except deform.ValidationFailure:
|
||||||
if raise_error:
|
if raise_error:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -1343,6 +1343,8 @@ class MasterView(View):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_row_model_title_plural(cls):
|
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())
|
return "{} Rows".format(cls.get_model_title())
|
||||||
|
|
||||||
def view_index(self):
|
def view_index(self):
|
||||||
|
@ -2395,7 +2397,9 @@ class MasterView(View):
|
||||||
return True
|
return True
|
||||||
return False
|
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)
|
obj = form.schema.objectify(data, context=form.model_instance)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
@ -2822,12 +2826,10 @@ class MasterView(View):
|
||||||
self.set_row_labels(form)
|
self.set_row_labels(form)
|
||||||
|
|
||||||
def validate_row_form(self, form):
|
def validate_row_form(self, form):
|
||||||
controls = self.request.POST.items()
|
if form.validate(newstyle=True):
|
||||||
try:
|
self.form_deserialized = form.validated
|
||||||
self.form_deserialized = form.validate(controls)
|
return True
|
||||||
except deform.ValidationFailure:
|
return False
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def get_row_action_url(self, action, row, mobile=False):
|
def get_row_action_url(self, action, row, mobile=False):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue