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
5b3a64ab
Commit
5b3a64ab
authored
Jul 17, 2016
by
Duc Anh Tran
Committed by
GitHub
Jul 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify modelconverter to support GeoPtProperty of appengine
parent
7d05926b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
fields.py
flask_admin/contrib/appengine/fields.py
+17
-0
form.py
flask_admin/contrib/appengine/form.py
+9
-0
No files found.
flask_admin/contrib/appengine/fields.py
0 → 100644
View file @
5b3a64ab
from
wtforms.fields
import
TextField
from
google.appengine.ext
import
ndb
import
decimal
class
GeoPtPropertyField
(
TextField
):
def
process_formdata
(
self
,
valuelist
):
if
valuelist
:
try
:
lat
,
lon
=
valuelist
[
0
]
.
split
(
','
)
self
.
data
=
ndb
.
GeoPt
(
decimal
.
Decimal
(
lat
.
strip
()),
decimal
.
Decimal
(
lon
.
strip
())
)
except
(
decimal
.
InvalidOperation
,
ValueError
):
raise
ValueError
(
'Not a valid coordinate location'
)
flask_admin/contrib/appengine/form.py
0 → 100644
View file @
5b3a64ab
from
wtforms_appengine.ndb
import
ModelConverter
from
.fields
import
GeoPtPropertyField
from
flask_admin.model.form
import
converts
class
AdminModelConverter
(
ModelConverter
):
@
converts
(
'GeoPt'
)
def
convert_GeoPtProperty
(
self
,
model
,
prop
,
kwargs
):
"""Returns a form field for a ``ndb.GeoPtProperty``."""
return
GeoPtPropertyField
(
**
kwargs
)
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