Commit 20bebac6 authored by Serge S. Koval's avatar Serge S. Koval

Fixed #378. Properly check if field is missing when using form rules

parent cd1763ba
...@@ -271,7 +271,7 @@ class Field(Macro): ...@@ -271,7 +271,7 @@ class Field(Macro):
""" """
field = getattr(form, self.field_name, None) field = getattr(form, self.field_name, None)
if not field: if field is None:
raise ValueError('Form %s does not have field %s' % (form, self.field_name)) raise ValueError('Form %s does not have field %s' % (form, self.field_name))
opts = {} opts = {}
......
...@@ -56,7 +56,7 @@ def create_models(db): ...@@ -56,7 +56,7 @@ def create_models(db):
# Relation # Relation
model1_id = db.Column(db.Integer, db.ForeignKey(Model1.id)) model1_id = db.Column(db.Integer, db.ForeignKey(Model1.id))
model1 = db.relationship(Model1) model1 = db.relationship(Model1, backref='model2')
db.create_all() db.create_all()
......
...@@ -122,3 +122,20 @@ def test_rule_field_set(): ...@@ -122,3 +122,20 @@ def test_rule_field_set():
ok_(pos1 > pos2) ok_(pos1 > pos2)
ok_(pos4 > pos1) ok_(pos4 > pos1)
ok_(pos3 == -1) ok_(pos3 == -1)
def test_rule_inlinefieldlist():
app, db, admin = setup()
Model1, Model2 = create_models(db)
db.create_all()
view = CustomModelView(Model1, db.session,
inline_models=(Model2,),
form_create_rules=('test1', 'model2'))
admin.add_view(view)
client = app.test_client()
rv = client.get('/admin/model1view/new/')
eq_(rv.status_code, 200)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment