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
731d14c1
Commit
731d14c1
authored
Feb 20, 2019
by
Serge Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQLAlchemy fixes, flake8 fixes
parent
ae01e5f4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
9 deletions
+15
-9
fields.py
flask_admin/contrib/geoa/fields.py
+3
-3
typefmt.py
flask_admin/contrib/geoa/typefmt.py
+3
-1
view.py
flask_admin/contrib/mongoengine/view.py
+2
-2
view.py
flask_admin/contrib/peewee/view.py
+2
-2
view.py
flask_admin/contrib/sqla/view.py
+5
-1
No files found.
flask_admin/contrib/geoa/fields.py
View file @
731d14c1
...
...
@@ -19,7 +19,7 @@ class GeoJSONField(JSONField):
super
(
GeoJSONField
,
self
)
.
__init__
(
label
,
validators
,
**
kwargs
)
self
.
web_srid
=
4326
self
.
srid
=
srid
if
self
.
srid
is
-
1
:
if
self
.
srid
==
-
1
:
self
.
transform_srid
=
self
.
web_srid
else
:
self
.
transform_srid
=
self
.
srid
...
...
@@ -30,7 +30,7 @@ class GeoJSONField(JSONField):
if
self
.
raw_data
:
return
self
.
raw_data
[
0
]
if
type
(
self
.
data
)
is
geoalchemy2
.
elements
.
WKBElement
:
if
self
.
srid
is
-
1
:
if
self
.
srid
==
-
1
:
return
self
.
session
.
scalar
(
func
.
ST_AsGeoJson
(
self
.
data
))
else
:
return
self
.
session
.
scalar
(
...
...
@@ -43,7 +43,7 @@ class GeoJSONField(JSONField):
def
process_formdata
(
self
,
valuelist
):
super
(
GeoJSONField
,
self
)
.
process_formdata
(
valuelist
)
if
str
(
self
.
data
)
is
''
:
if
str
(
self
.
data
)
==
''
:
self
.
data
=
None
if
self
.
data
is
not
None
:
web_shape
=
self
.
session
.
scalar
(
...
...
flask_admin/contrib/geoa/typefmt.py
View file @
731d14c1
...
...
@@ -17,8 +17,10 @@ def geom_formatter(view, value):
"data-tile-layer-url"
:
view
.
tile_layer_url
,
"data-tile-layer-attribution"
:
view
.
tile_layer_attribution
})
if
value
.
srid
is
-
1
:
if
value
.
srid
==
-
1
:
value
.
srid
=
4326
geojson
=
view
.
session
.
query
(
view
.
model
)
.
with_entities
(
func
.
ST_AsGeoJSON
(
value
))
.
scalar
()
return
Markup
(
'<textarea
%
s>
%
s</textarea>'
%
(
params
,
geojson
))
...
...
flask_admin/contrib/mongoengine/view.py
View file @
731d14c1
...
...
@@ -364,8 +364,8 @@ class ModelView(BaseModelView):
# Check type
if
(
field_type
not
in
self
.
allowed_search_types
):
raise
Exception
(
'Can only search on text columns. '
+
'Failed to setup search for "
%
s"'
%
p
)
raise
Exception
(
'Can only search on text columns. '
+
'Failed to setup search for "
%
s"'
%
p
)
self
.
_search_fields
.
append
(
p
)
...
...
flask_admin/contrib/peewee/view.py
View file @
731d14c1
...
...
@@ -221,8 +221,8 @@ class ModelView(BaseModelView):
# Check type
if
not
isinstance
(
p
,
(
CharField
,
TextField
)):
raise
Exception
(
'Can only search on text columns. '
+
'Failed to setup search for "
%
s"'
%
p
)
raise
Exception
(
'Can only search on text columns. '
+
'Failed to setup search for "
%
s"'
%
p
)
self
.
_search_fields
.
append
(
p
)
...
...
flask_admin/contrib/sqla/view.py
View file @
731d14c1
...
...
@@ -3,7 +3,7 @@ import warnings
import
inspect
from
sqlalchemy.orm.attributes
import
InstrumentedAttribute
from
sqlalchemy.orm.base
import
manager_of_class
from
sqlalchemy.orm.base
import
manager_of_class
,
instance_state
from
sqlalchemy.orm
import
joinedload
,
aliased
from
sqlalchemy.sql.expression
import
desc
from
sqlalchemy
import
Boolean
,
Table
,
func
,
or_
...
...
@@ -1115,6 +1115,10 @@ class ModelView(BaseModelView):
"""
try
:
model
=
self
.
_manager
.
new_instance
()
# TODO: We need a better way to create model instances and stay compatible with SQLAlchemy __init__() behavior
state
=
instance_state
(
model
)
self
.
_manager
.
dispatch
.
init
(
state
,
[],
{})
form
.
populate_obj
(
model
)
self
.
session
.
add
(
model
)
self
.
_on_model_change
(
form
,
model
,
True
)
...
...
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