Browse files

Support not nullable boolean fields, and fix filtering by boolean fie…

…lds.
  • Loading branch information...
1 parent ff887bd commit 87abc5757473768946db7d2a124d68aaf947c292 @flowblok flowblok committed Sep 17, 2012
Showing with 4 additions and 2 deletions.
  1. +1 −0 AUTHORS
  2. +2 −1 flask_admin/contrib/sqlamodel/form.py
  3. +1 −1 flask_admin/model/filters.py
View
1 AUTHORS
@@ -15,3 +15,4 @@ Patches and Suggestions
- Salem Harrache <salem@harrache.info>
- F. Gabriel Gosselin
- Leonardinius <leonids.maslovs@galeoconsulting.com>
+- Peter Ward <peteraward@gmail.com>
View
3 flask_admin/contrib/sqlamodel/form.py
@@ -1,4 +1,5 @@
from wtforms import fields, validators
+from sqlalchemy import Boolean
from flask.ext.admin import form
from flask.ext.admin.model.form import converts, ModelConverterBase, InlineFormAdmin
@@ -125,7 +126,7 @@ def convert(self, model, mapper, prop, field_args, hidden_pk):
model,
column))
- if not column.nullable:
+ if not column.nullable and not isinstance(column.type, Boolean):
kwargs['validators'].append(validators.Required())
# Apply label
View
2 flask_admin/model/filters.py
@@ -77,7 +77,7 @@ class BaseBooleanFilter(BaseFilter):
"""
Base boolean filter, uses fixed list of options.
"""
- def __init__(self, name, data_type=None):
+ def __init__(self, name, options=None, data_type=None):
super(BaseBooleanFilter, self).__init__(name,
(('1', lazy_gettext('Yes')),
('0', lazy_gettext('No'))),

0 comments on commit 87abc57

Please sign in to comment.