tweaked formalchemy fieldset
This commit is contained in:
parent
b846ecdd3f
commit
f5054c58be
2 changed files with 7 additions and 6 deletions
|
@ -72,14 +72,15 @@ class FieldSet(formalchemy.FieldSet):
|
||||||
prettify = staticmethod(prettify)
|
prettify = staticmethod(prettify)
|
||||||
|
|
||||||
def __init__(self, model, class_name=None, crud_title=None, url=None,
|
def __init__(self, model, class_name=None, crud_title=None, url=None,
|
||||||
route_name=None, url_action=None, url_cancel=None, **kwargs):
|
route_name=None, action_url='', list_url=None, cancel_url=None, **kwargs):
|
||||||
formalchemy.FieldSet.__init__(self, model, **kwargs)
|
super(FieldSet, self).__init__(model, **kwargs)
|
||||||
self.class_name = class_name or self._original_cls.__name__.lower()
|
self.class_name = class_name or self._original_cls.__name__.lower()
|
||||||
self.crud_title = crud_title or prettify(self.class_name)
|
self.crud_title = crud_title or prettify(self.class_name)
|
||||||
self.edit = isinstance(model, self._original_cls)
|
self.edit = isinstance(model, self._original_cls)
|
||||||
self.route_name = route_name or (self.class_name + 's')
|
self.route_name = route_name or (self.class_name + 's')
|
||||||
self.url_action = url_action or url(self.route_name)
|
self.action_url = action_url
|
||||||
self.url_cancel = url_cancel or url(self.route_name)
|
self.list_url = list_url
|
||||||
|
self.cancel_url = cancel_url or self.list_url
|
||||||
self.allow_continue = kwargs.pop('allow_continue', False)
|
self.allow_continue = kwargs.pop('allow_continue', False)
|
||||||
|
|
||||||
def get_display_text(self):
|
def get_display_text(self):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<% _focus_rendered = False %>
|
<% _focus_rendered = False %>
|
||||||
|
|
||||||
<div class="fieldset-form ${class_}">
|
<div class="fieldset-form ${class_}">
|
||||||
${h.form(fieldset.url_action+('?uuid='+fieldset.model.uuid) if fieldset.edit else '', enctype='multipart/form-data')}
|
${h.form(fieldset.action_url+('?uuid='+fieldset.model.uuid) if fieldset.edit else '', enctype='multipart/form-data')}
|
||||||
|
|
||||||
% for error in fieldset.errors.get(None, []):
|
% for error in fieldset.errors.get(None, []):
|
||||||
<div class="fieldset-error">${error}</div>
|
<div class="fieldset-error">${error}</div>
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
$('button.cancel').click(function() {
|
$('button.cancel').click(function() {
|
||||||
location.href = '${fieldset.url_cancel}';
|
location.href = '${fieldset.cancel_url}';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue