api: makes sure field type is always part of the schema

This commit is contained in:
Frédéric Péters 2014-12-25 11:20:57 +01:00
parent 26d3c95173
commit 4c8f8278b4
2 changed files with 3 additions and 0 deletions

View File

@ -142,6 +142,7 @@ def test_formdef_schema():
resp = get_app(pub).get('/test/schema')
assert resp.json['name'] == 'test'
assert resp.json['fields'][0]['label'] == 'foobar'
assert resp.json['fields'][0]['type'] == 'string'
def test_categories():
Category.wipe()

View File

@ -150,6 +150,8 @@ class Field(object):
if hasattr(self, attribute) and getattr(self, attribute) is not None:
val = getattr(self, attribute)
field[attribute] = val
if not 'type' in field:
field['type'] = self.key
return field
def init_with_json(self, elem, include_id=False):