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
391bdc8e
Commit
391bdc8e
authored
Sep 05, 2016
by
Serge S. Koval
Committed by
GitHub
Sep 05, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1340 from ei-grad/master
Fix geoa.GeoJSONField
parents
22e206c4
b9c71bbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
fields.py
flask_admin/contrib/geoa/fields.py
+4
-3
test_basic.py
flask_admin/tests/geoa/test_basic.py
+30
-1
No files found.
flask_admin/contrib/geoa/fields.py
View file @
391bdc8e
...
...
@@ -45,20 +45,21 @@ class GeoJSONField(JSONField):
return
self
.
raw_data
[
0
]
if
type
(
self
.
data
)
is
geoalchemy2
.
elements
.
WKBElement
:
if
self
.
srid
is
-
1
:
self
.
data
=
self
.
session
.
scalar
(
return
self
.
session
.
scalar
(
func
.
ST_AsGeoJson
(
self
.
_flip_coordinates
(
self
.
data
)
)
)
else
:
self
.
data
=
self
.
session
.
scalar
(
return
self
.
session
.
scalar
(
func
.
ST_AsGeoJson
(
self
.
_flip_coordinates
(
func
.
ST_Transform
(
self
.
data
,
self
.
web_srid
)
)
)
)
return
super
(
GeoJSONField
,
self
)
.
_value
()
else
:
return
''
def
process_formdata
(
self
,
valuelist
):
super
(
GeoJSONField
,
self
)
.
process_formdata
(
valuelist
)
...
...
flask_admin/tests/geoa/test_basic.py
View file @
391bdc8e
...
...
@@ -6,7 +6,7 @@ from flask_admin.contrib.geoa import ModelView
from
flask_admin.contrib.geoa.fields
import
GeoJSONField
from
geoalchemy2
import
Geometry
from
geoalchemy2.shape
import
to_shape
from
nose.tools
import
eq_
from
nose.tools
import
eq_
,
ok_
from
.
import
setup
...
...
@@ -96,6 +96,8 @@ def test_model():
url
=
'/admin/geomodel/edit/?id=
%
s'
%
model
.
id
rv
=
client
.
get
(
url
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
r' name="multi">{"type":"MultiPoint","coordinates":[[100,0],[101,1]]}</textarea>'
in
data
)
# rv = client.post(url, data={
# "name": "edited",
...
...
@@ -166,3 +168,30 @@ def test_mapbox_fix_point_coordinates():
# Reversed order again, so that it's parsed correctly by leaflet
eq_
(
p
[
'coordinates'
][
0
],
10.0
)
eq_
(
p
[
'coordinates'
][
1
],
125.8
)
def
test_none
():
app
,
db
,
admin
=
setup
()
GeoModel
=
create_models
(
db
)
db
.
create_all
()
GeoModel
.
query
.
delete
()
db
.
session
.
commit
()
view
=
ModelView
(
GeoModel
,
db
.
session
)
admin
.
add_view
(
view
)
# Make some test clients
client
=
app
.
test_client
()
rv
=
client
.
post
(
'/admin/geomodel/new/'
,
data
=
{
"name"
:
"test1"
,
})
eq_
(
rv
.
status_code
,
302
)
model
=
db
.
session
.
query
(
GeoModel
)
.
first
()
url
=
'/admin/geomodel/edit/?id=
%
s'
%
model
.
id
rv
=
client
.
get
(
url
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
r' name="point"></textarea>'
in
data
)
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