Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
1ce20ca9
Commit
1ce20ca9
authored
Jul 23, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if value is really grid fs proxy object. Related to #263
parent
e26e4185
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
helpers.py
flask_admin/contrib/mongoengine/helpers.py
+1
-1
widgets.py
flask_admin/contrib/mongoengine/widgets.py
+4
-2
No files found.
flask_admin/contrib/mongoengine/helpers.py
View file @
1ce20ca9
...
@@ -11,7 +11,7 @@ def make_gridfs_args(value):
...
@@ -11,7 +11,7 @@ def make_gridfs_args(value):
def
make_thumb_args
(
value
):
def
make_thumb_args
(
value
):
if
value
.
thumbnail
:
if
getattr
(
value
,
'thumbnail'
,
None
)
:
args
=
{
args
=
{
'id'
:
value
.
thumbnail
.
_id
,
'id'
:
value
.
thumbnail
.
_id
,
'coll'
:
value
.
collection_name
'coll'
:
value
.
collection_name
...
...
flask_admin/contrib/mongoengine/widgets.py
View file @
1ce20ca9
...
@@ -3,6 +3,8 @@ from wtforms.widgets import HTMLString, html_params
...
@@ -3,6 +3,8 @@ from wtforms.widgets import HTMLString, html_params
from
jinja2
import
escape
from
jinja2
import
escape
from
flask
import
url_for
from
flask
import
url_for
from
mongoengine.fields
import
GridFSProxy
,
ImageGridFsProxy
from
.
import
helpers
from
.
import
helpers
...
@@ -16,7 +18,7 @@ class MongoFileInput(object):
...
@@ -16,7 +18,7 @@ class MongoFileInput(object):
kwargs
.
setdefault
(
'id'
,
field
.
id
)
kwargs
.
setdefault
(
'id'
,
field
.
id
)
placeholder
=
''
placeholder
=
''
if
field
.
data
:
if
field
.
data
and
isinstance
(
field
.
data
,
GridFSProxy
)
:
data
=
field
.
data
data
=
field
.
data
placeholder
=
self
.
template
%
{
placeholder
=
self
.
template
%
{
...
@@ -41,7 +43,7 @@ class MongoImageInput(object):
...
@@ -41,7 +43,7 @@ class MongoImageInput(object):
kwargs
.
setdefault
(
'id'
,
field
.
id
)
kwargs
.
setdefault
(
'id'
,
field
.
id
)
placeholder
=
''
placeholder
=
''
if
field
.
data
:
if
field
.
data
and
isinstance
(
field
.
data
,
ImageGridFsProxy
)
:
args
=
helpers
.
make_thumb_args
(
field
.
data
)
args
=
helpers
.
make_thumb_args
(
field
.
data
)
placeholder
=
self
.
template
%
{
placeholder
=
self
.
template
%
{
'thumb'
:
url_for
(
'.api_file_view'
,
**
args
)
'thumb'
:
url_for
(
'.api_file_view'
,
**
args
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment