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
cdccdcc7
Commit
cdccdcc7
authored
Mar 31, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit tests.
parent
b192ea76
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
11 deletions
+99
-11
TODO.txt
TODO.txt
+0
-5
base.py
flask_adminex/base.py
+6
-5
filters.py
flask_adminex/model/filters.py
+0
-1
__init__.py
tests/__init__.py
+0
-0
mock.py
tests/mock.py
+7
-0
test_base.py
tests/test_base.py
+86
-0
No files found.
TODO.txt
View file @
cdccdcc7
...
...
@@ -6,14 +6,9 @@
- List display callables
- Search
- Rename init_search
- Built-in filtering support
- Configurable operations (=, >, <, etc)
- Callable operations
- Paginator class
- Custom CSS/JS in admin interface
- SQLA Model Admin
- Do not rely on id as a primary key
- Built-in filtering support
- Many2Many support
- Verify if it is working properly
- WYSIWYG editor support?
...
...
flask_adminex/base.py
View file @
cdccdcc7
...
...
@@ -64,10 +64,6 @@ class AdminViewMeta(type):
# Wrap views
setattr
(
cls
,
p
,
_wrap_view
(
attr
))
# Default view
if
cls
.
_default_view
is
None
and
cls
.
_urls
:
raise
Exception
(
'Missing default view for the admin view
%
s'
%
classname
)
class
BaseView
(
object
):
"""
...
...
@@ -111,6 +107,10 @@ class BaseView(object):
self
.
admin
=
None
self
.
blueprint
=
None
# Default view
if
self
.
_default_view
is
None
:
raise
Exception
(
'Attempted to instantiate admin view
%
s without defailt view'
%
self
.
__class__
.
__name__
)
def
create_blueprint
(
self
,
admin
):
"""
Create Flask blueprint.
...
...
@@ -156,7 +156,7 @@ class BaseView(object):
`kwargs`
Template arguments
"""
# Store
# Store
self as admin_view
kwargs
[
'admin_view'
]
=
self
return
render_template
(
template
,
**
kwargs
)
...
...
@@ -291,6 +291,7 @@ class Admin(object):
index_view
=
AdminIndexView
()
self
.
app
=
app
self
.
index_view
=
index_view
# Add predefined index view
self
.
add_view
(
index_view
)
...
...
flask_adminex/model/filters.py
View file @
cdccdcc7
...
...
@@ -110,7 +110,6 @@ def convert(*args):
See :mod:`flask.ext.adminex.ext.sqlamodel.filters` for usage example.
"""
def
_inner
(
func
):
print
args
func
.
_converter_for
=
args
return
func
return
_inner
...
...
tests/__init__.py
0 → 100644
View file @
cdccdcc7
tests/mock.py
0 → 100644
View file @
cdccdcc7
from
flask.ext.adminex
import
base
class
MockView
(
base
.
BaseView
):
@
base
.
expose
(
'/'
)
def
index
(
self
):
return
None
tests/test_base.py
0 → 100644
View file @
cdccdcc7
from
nose.tools
import
ok_
,
eq_
from
flask
import
Flask
from
flask.ext.adminex
import
base
from
.mock
import
MockView
def
test_baseview_defaults
():
view
=
MockView
()
eq_
(
view
.
name
,
None
)
eq_
(
view
.
category
,
None
)
eq_
(
view
.
endpoint
,
None
)
eq_
(
view
.
url
,
None
)
eq_
(
view
.
static_folder
,
None
)
eq_
(
view
.
admin
,
None
)
eq_
(
view
.
blueprint
,
None
)
def
test_base_defaults
():
admin
=
base
.
Admin
()
eq_
(
admin
.
name
,
'Admin'
)
eq_
(
admin
.
url
,
'/admin'
)
eq_
(
admin
.
app
,
None
)
ok_
(
admin
.
index_view
is
not
None
)
# Check if default view was added
eq_
(
len
(
admin
.
_views
),
1
)
eq_
(
admin
.
_views
[
0
],
admin
.
index_view
)
def
test_base_registration
():
app
=
Flask
(
__name__
)
admin
=
base
.
Admin
(
app
)
eq_
(
admin
.
app
,
app
)
ok_
(
admin
.
index_view
.
blueprint
is
not
None
)
def
test_baseview_registration
():
admin
=
base
.
Admin
()
view
=
MockView
()
bp
=
view
.
create_blueprint
(
admin
)
# Base properties
eq_
(
view
.
admin
,
admin
)
ok_
(
view
.
blueprint
is
not
None
)
# Calculated properties
eq_
(
view
.
endpoint
,
'mockview'
)
eq_
(
view
.
url
,
'/admin/mockview'
)
eq_
(
view
.
name
,
'Mock View'
)
eq_
(
view
.
_urls
,
[(
'/'
,
'index'
,
(
'GET'
,))])
# Verify generated blueprint properties
eq_
(
bp
.
name
,
view
.
endpoint
)
eq_
(
bp
.
url_prefix
,
view
.
url
)
eq_
(
bp
.
template_folder
,
'templates'
)
eq_
(
bp
.
static_folder
,
view
.
static_folder
)
# Verify customizations
view
=
MockView
(
name
=
'Test'
,
endpoint
=
'foobar'
)
view
.
create_blueprint
(
base
.
Admin
())
eq_
(
view
.
name
,
'Test'
)
eq_
(
view
.
endpoint
,
'foobar'
)
eq_
(
view
.
url
,
'/admin/foobar'
)
view
=
MockView
(
url
=
'test'
)
view
.
create_blueprint
(
base
.
Admin
())
eq_
(
view
.
url
,
'/admin/test'
)
view
=
MockView
(
url
=
'/test/test'
)
view
.
create_blueprint
(
base
.
Admin
())
eq_
(
view
.
url
,
'/test/test'
)
def
verify_baseview_urls
():
app
=
Flask
(
__name__
)
admin
=
base
.
Admin
(
app
)
view
=
Dummy
()
admin
.
add_view
(
view
)
eq_
(
len
(
view
.
_urls
,
1
))
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