Skip to content
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Commits on Dec 17, 2012
@ArtemSerga ArtemSerga #3 - Add SQAlchemy specific column_type_formatter ac1c520
Commits on Dec 27, 2012
@mrjoes Merge pull request #131 from ArtemSerga/3
#3 - Add SQAlchemy specific column_type_formatter
2078a29
View
11 flask_admin/contrib/mongoengine/typefmt.py
@@ -1,9 +1,8 @@
from mongoengine.base import BaseList
-
from flask.ext.admin.model.typefmt import DEFAULT_FORMATTERS
-def mongoengine_list_formatter(values):
+def list_formatter(values):
"""
Return string with comma separated values
@@ -13,7 +12,7 @@ def mongoengine_list_formatter(values):
return u', '.join(unicode(v) for v in values)
-MONGOENGINE_FORMATTERS = dict(DEFAULT_FORMATTERS)
-MONGOENGINE_FORMATTERS.update({
- BaseList: mongoengine_list_formatter
- })
+DEFAULT_FORMATTERS = DEFAULT_FORMATTERS.copy()
+DEFAULT_FORMATTERS.update({
+ BaseList: list_formatter
+})
View
4 flask_admin/contrib/mongoengine/view.py
@@ -12,7 +12,7 @@
from flask.ext.admin.form import BaseForm
from .filters import FilterConverter, BaseMongoEngineFilter
from .form import model_form, CustomModelConverter
-from .typefmt import MONGOENGINE_FORMATTERS
+from .typefmt import DEFAULT_FORMATTERS
from .tools import parse_like_term
@@ -76,7 +76,7 @@ class MyAdminView(ModelView):
Override this attribute to use non-default converter.
"""
- column_type_formatters = MONGOENGINE_FORMATTERS
+ column_type_formatters = DEFAULT_FORMATTERS
"""
Customized type formatters for MongoEngine backend
"""
View
8 flask_admin/contrib/sqlamodel/typefmt.py
@@ -0,0 +1,8 @@
+from flask.ext.admin.model.typefmt import DEFAULT_FORMATTERS, list_formatter
+from sqlalchemy.orm.collections import InstrumentedList
+
+
+DEFAULT_FORMATTERS = DEFAULT_FORMATTERS.copy()
+DEFAULT_FORMATTERS.update({
+ InstrumentedList: list_formatter
+})
View
3 flask_admin/contrib/sqlamodel/view.py
@@ -13,6 +13,7 @@
from flask.ext.admin.actions import action
from flask.ext.admin.contrib.sqlamodel import form, filters, tools
+from .typefmt import DEFAULT_FORMATTERS
class ModelView(BaseModelView):
@@ -215,6 +216,8 @@ class MyModel1View(Base):
column_labels = {'models': 'Hello'}
"""
+ column_type_formatters = DEFAULT_FORMATTERS
+
def __init__(self, model, session,
name=None, category=None, endpoint=None, url=None):
"""

No commit comments for this range

Something went wrong with that request. Please try again.