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
2d3d1d63
Commit
2d3d1d63
authored
Jun 02, 2015
by
Petrus J.v.Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand geo-alchemy example.
parent
2f280a80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
4 deletions
+39
-4
app.py
examples/geo-alchemy/app.py
+39
-4
No files found.
examples/geo-alchemy/app.py
View file @
2d3d1d63
...
@@ -16,16 +16,46 @@ app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://flask_admin_geo:f
...
@@ -16,16 +16,46 @@ app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://flask_admin_geo:f
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
db
=
SQLAlchemy
(
app
)
db
=
SQLAlchemy
(
app
)
app
.
config
[
'MAPBOX_MAP_ID'
]
=
"..."
app
.
config
[
'MAPBOX_MAP_ID'
]
=
'...'
app
.
config
[
'MAPBOX_ACCESS_TOKEN'
]
=
"..."
app
.
config
[
'MAPBOX_ACCESS_TOKEN'
]
=
'...'
class
Location
(
db
.
Model
):
class
Point
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
)
name
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
)
point
=
db
.
Column
(
Geometry
(
"POINT"
))
point
=
db
.
Column
(
Geometry
(
"POINT"
))
class
MultiPoint
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
)
point
=
db
.
Column
(
Geometry
(
"MULTIPOINT"
))
class
Polygon
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
)
point
=
db
.
Column
(
Geometry
(
"POLYGON"
))
class
MultiPolygon
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
)
point
=
db
.
Column
(
Geometry
(
"MULTIPOLYGON"
))
class
LineString
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
)
point
=
db
.
Column
(
Geometry
(
"LINESTRING"
))
class
MultiLineString
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
)
point
=
db
.
Column
(
Geometry
(
"MULTILINESTRING"
))
# Flask views
# Flask views
@
app
.
route
(
'/'
)
@
app
.
route
(
'/'
)
def
index
():
def
index
():
...
@@ -35,7 +65,12 @@ def index():
...
@@ -35,7 +65,12 @@ def index():
admin
=
admin
.
Admin
(
app
,
name
=
'Example: GeoAlchemy'
)
admin
=
admin
.
Admin
(
app
,
name
=
'Example: GeoAlchemy'
)
# Add views
# Add views
admin
.
add_view
(
ModelView
(
Location
,
db
.
session
))
admin
.
add_view
(
ModelView
(
Point
,
db
.
session
,
category
=
'Points'
))
admin
.
add_view
(
ModelView
(
MultiPoint
,
db
.
session
,
category
=
'Points'
))
admin
.
add_view
(
ModelView
(
Polygon
,
db
.
session
,
category
=
'Polygons'
))
admin
.
add_view
(
ModelView
(
MultiPolygon
,
db
.
session
,
category
=
'Polygons'
))
admin
.
add_view
(
ModelView
(
LineString
,
db
.
session
,
category
=
'Lines'
))
admin
.
add_view
(
ModelView
(
MultiLineString
,
db
.
session
,
category
=
'Lines'
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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