Skip to content
Browse files

Cleaned up default type formatters

  • Loading branch information...
1 parent 2078a29 commit f7e0f312096f678dd7e4b27112fed4c97b2a984e @mrjoes committed Dec 27, 2012
View
14 flask_admin/contrib/mongoengine/typefmt.py
@@ -1,18 +1,8 @@
from mongoengine.base import BaseList
-from flask.ext.admin.model.typefmt import DEFAULT_FORMATTERS
+from flask.ext.admin.model.typefmt import BASE_FORMATTERS, list_formatter
-def list_formatter(values):
- """
- Return string with comma separated values
-
- :param values:
- Value to check
- """
- return u', '.join(unicode(v) for v in values)
-
-
-DEFAULT_FORMATTERS = DEFAULT_FORMATTERS.copy()
+DEFAULT_FORMATTERS = BASE_FORMATTERS.copy()
DEFAULT_FORMATTERS.update({
BaseList: list_formatter
})
View
4 flask_admin/contrib/sqlamodel/typefmt.py
@@ -1,8 +1,8 @@
-from flask.ext.admin.model.typefmt import DEFAULT_FORMATTERS, list_formatter
+from flask.ext.admin.model.typefmt import BASE_FORMATTERS, list_formatter
from sqlalchemy.orm.collections import InstrumentedList
-DEFAULT_FORMATTERS = DEFAULT_FORMATTERS.copy()
+DEFAULT_FORMATTERS = BASE_FORMATTERS.copy()
DEFAULT_FORMATTERS.update({
InstrumentedList: list_formatter
})
View
4 flask_admin/model/base.py
@@ -109,7 +109,7 @@ class MyModelView(BaseModelView):
from flask.ext.admin import typefmt
- MY_DEFAULT_FORMATTERS = dict(typefmt.DEFAULT_FORMATTERS).extend({
+ MY_DEFAULT_FORMATTERS = dict(typefmt.BASE_FORMATTERS).extend({
type(None): typefmt.null_formatter
})
@@ -335,7 +335,7 @@ def _refresh_cache(self):
# Type formatters
if self.column_type_formatters is None:
- self.column_type_formatters = dict(typefmt.DEFAULT_FORMATTERS)
+ self.column_type_formatters = dict(typefmt.BASE_FORMATTERS)
if self.column_descriptions is None:
self.column_descriptions = dict()
View
2 flask_admin/model/typefmt.py
@@ -41,7 +41,7 @@ def list_formatter(values):
return u', '.join(unicode(v) for v in values)
-DEFAULT_FORMATTERS = {
+BASE_FORMATTERS = {
type(None): empty_formatter,
bool: bool_formatter,
list: list_formatter,

0 comments on commit f7e0f31

Please sign in to comment.
Something went wrong with that request. Please try again.