diff --git a/app/templates/wtf.html.j2 b/app/templates/wtf.html.j2 index 730fd337..a85042aa 100644 --- a/app/templates/wtf.html.j2 +++ b/app/templates/wtf.html.j2 @@ -1,47 +1,42 @@ {% macro render_field(field) %} {% if field.type == 'BooleanField' %} {{ render_boolean_field(field, *args, **kwargs) }} - {% elif field.type == 'DecimalRangeField' %} - {{ render_decimal_range_field(field, *args, **kwargs) }} + {% elif field.type == 'FileField' %} + {{ render_file_field(field, *args, **kwargs) }} + {% elif field.type == 'IntegerField' %} + {{ render_integer_field(field, *args, **kwargs) }} + {% elif field.type == 'MultipleFileField' %} + {{ render_multiple_file_field(field, *args, **kwargs) }} {% elif field.type == 'SubmitField' %} {{ render_submit_field(field, *args, **kwargs) }} - {% elif field.type in ['FileField', 'MultipleFileField'] %} - {{ render_file_field(field, *args, **kwargs) }} + {% elif field.type == 'TextAreaField' %} + {{ render_text_area_field(field, *args, **kwargs) }} {% else %} - {% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %} - {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %} - {% else %} - {% set tmp = kwargs.update({'class_': 'validate'}) %} - {% endif %} {{ render_generic_field(field, *args, **kwargs) }} {% endif %} {% endmacro %} + {% macro render_boolean_field(field) %} - {% set label = kwargs.pop('label', True) %} -
- {% if 'material_icon' in kwargs %} - {{ kwargs.pop('material_icon') }} - {% endif %} +
- {% for error in field.errors %} - {{ error }} - {% endfor %}
{% endmacro %} + {% macro render_file_field(field) %} {% set placeholder = kwargs.pop('placeholder', '') %} +
{{ field.label.text }} - {{ field(*args, **kwargs) }} +
@@ -52,50 +47,78 @@
{% endmacro %} -{% macro render_generic_field(field) %} - {% if field.type == 'TextAreaField' and 'materialize-textarea' not in kwargs['class_'] %} - {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' materialize-textarea'}) %} - {% elif field.type == 'IntegerField' %} - {% set tmp = kwargs.update({'type': 'number'}) %} - {% endif %} - {% set label = kwargs.pop('label', True) %} -
- {% if 'material_icon' in kwargs %} - {{ kwargs.pop('material_icon') }} - {% endif %} - {{ field(*args, **kwargs) }} - {% if label %} - {{ field.label }} - {% endif %} + +{% macro render_multiple_file_field(field) %} + {% set placeholder = kwargs.pop('placeholder', '') %} + +
+
+ {{ field.label.text }} + +
+
+ +
{% for error in field.errors %} {{ error }} {% endfor %}
{% endmacro %} + +{% macro render_integer_field(field) %} +
+ {% if 'material_icon' in kwargs %} + {{ kwargs.pop('material_icon') }} + {% endif %} + + + {% for error in field.errors %} + {{ error }} + {% endfor %} +
+{% endmacro %} + + {% macro render_submit_field(field) %} - {% if 'class_' in kwargs and 'btn' not in kwargs['class_'] %} - {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' btn'}) %} - {% else %} - {% set tmp = kwargs.update({'class_': 'btn'}) %} - {% endif %} - {% if 'waves-effect' not in kwargs['class_'] %} - {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' waves-effect'}) %} - {% endif %} - {% if 'waves-light' not in kwargs['class_'] %} - {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' waves-light'}) %} - {% endif %} - {% endmacro %} + + +{% macro render_text_area_field(field) %} +
+ {% if 'material_icon' in kwargs %} + {{ kwargs.pop('material_icon') }} + {% endif %} + + + {% for error in field.errors %} + {{ error }} + {% endfor %} +
+{% endmacro %} + + +{% macro render_generic_field(field) %} + {% set classes_ = kwargs.pop('class_', '').split(' ') %} + {% if 'validate' not in classes_ %} + {% set _ = classes_.append('validate') %} + {% endif %} + {% set _ = kwargs.update({'class_': ' '.join(classes_)}) %} + +
+ {% if 'material_icon' in kwargs %} + {{ kwargs.pop('material_icon') }} + {% endif %} + {{ field(*args, **kwargs) }} + {{ field.label }} + {% for error in field.errors %} + {{ error }} + {% endfor %} +
+{% endmacro %}