Skip to content

Commit

Permalink
Form scaffold template should understand how to render integer and fl…
Browse files Browse the repository at this point in the history
…oat fields.

closes #583
  • Loading branch information
davidmiller committed Mar 19, 2017
1 parent 738c444 commit 6f59c68
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions opal/scaffolding/record_templates/record_form.jinja2
Expand Up @@ -7,4 +7,6 @@
{% if f['type'] == 'date_time' %}{{ '{' + '% datetimepicker ' }} field="{{ f["model"] }}.{{ f["name"] }}" {{' %' +'}' }}{% endif %}
{% if f['type'] == 'text' %}{{ '{' + '% textarea ' }} field="{{ f["model"] }}.{{ f["name"] }}" {{' %' +'}' }}{% endif %}
{% if f['type'] == 'boolean' or f['type'] == 'null_boolean' %}{{ '{' + '% checkbox ' }} field="{{ f["model"] }}.{{ f["name"] }}" {{' %' +'}' }}{% endif %}
{% if f['type'] == 'float' %}{{ '{' + '% input ' }} field="{{ f["model"] }}.{{ f["name"] }}" {{' %' +'}' }}{% endif %}
{% if f['type'] == 'integer' %}{{ '{' + '% input ' }} field="{{ f["model"] }}.{{ f["name"] }}" {{' %' +'}' }}{% endif %}
{% endif %}{% endfor %}
30 changes: 30 additions & 0 deletions opal/tests/test_scaffold.py
Expand Up @@ -382,6 +382,36 @@ def test_boolean_render(self, build_field_schema, lshift):
'{% load forms %}\n{% checkbox field="Colour.name" %}'
)

@patch.object(Colour, "build_field_schema")
def test_integer_render(self, build_field_schema, lshift):
build_field_schema.return_value = {
'lookup_list': None,
'model': 'Colour',
'name': 'number',
'title': 'Number',
'type': 'integer'
},
scaffold_path = ffs.Path(settings.PROJECT_PATH)/'scaffolding'
create_form_template_for(Colour, scaffold_path)
lshift.assert_called_once_with(
'{% load forms %}\n{% input field="Colour.number" %}'
)

@patch.object(Colour, "build_field_schema")
def test_float_render(self, build_field_schema, lshift):
build_field_schema.return_value = {
'lookup_list': None,
'model': 'Colour',
'name': 'number',
'title': 'Number',
'type': 'float'
},
scaffold_path = ffs.Path(settings.PROJECT_PATH)/'scaffolding'
create_form_template_for(Colour, scaffold_path)
lshift.assert_called_once_with(
'{% load forms %}\n{% input field="Colour.number" %}'
)

@patch('ffs.Path.__bool__')
@patch('ffs.Path.__nonzero__')
@patch('ffs.Path.mkdir')
Expand Down

0 comments on commit 6f59c68

Please sign in to comment.