|
@ -1,15 +1,15 @@ |
|
|
from crispy_forms_foundation.layout import (HTML, Column, Div, Fieldset, |
|
|
from crispy_forms.bootstrap import FormActions |
|
|
Layout, Row, Submit) |
|
|
from crispy_forms.layout import Submit, Layout, Div, Fieldset, HTML |
|
|
from django.utils.translation import ugettext as _ |
|
|
from django.utils.translation import ugettext as _ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_column(name_span): |
|
|
def to_column(name_span): |
|
|
fieldname, span = name_span |
|
|
fieldname, span = name_span |
|
|
return Column(fieldname, css_class='large-%d' % span) |
|
|
return Div(fieldname, css_class='col-sm-%d' % span) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_row(names_spans): |
|
|
def to_row(names_spans): |
|
|
return Row(*list(map(to_column, names_spans))) |
|
|
return Div(*map(to_column, names_spans), css_class='row-fluid') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_fieldsets(fields): |
|
|
def to_fieldsets(fields): |
|
@ -25,13 +25,9 @@ def to_fieldsets(fields): |
|
|
class SaplFormLayout(Layout): |
|
|
class SaplFormLayout(Layout): |
|
|
|
|
|
|
|
|
def __init__(self, *fields): |
|
|
def __init__(self, *fields): |
|
|
buttons = Div( |
|
|
buttons = FormActions( |
|
|
|
|
|
Submit('save', _('Enviar'), css_class='btn btn-primary '), |
|
|
HTML('<a href="{{ view.cancel_url }}"' |
|
|
HTML('<a href="{{ view.cancel_url }}"' |
|
|
' class="button radius alert">%s</a>' % _('Cancelar')), |
|
|
' class="btn btn-inverse">%s</a>' % _('Cancelar'))) |
|
|
Submit('submit', _('Enviar'), |
|
|
_fields = list(to_fieldsets(fields)) + [to_row([(buttons, 12)])] |
|
|
css_class='button radius success right'), |
|
|
|
|
|
css_class='radius clearfix' |
|
|
|
|
|
) |
|
|
|
|
|
_fields = list(to_fieldsets(fields)) + \ |
|
|
|
|
|
[Row(Column(buttons, css_class='clearfix'))] |
|
|
|
|
|
super(SaplFormLayout, self).__init__(*_fields) |
|
|
super(SaplFormLayout, self).__init__(*_fields) |
|
|