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
5066d6d2
Commit
5066d6d2
authored
Oct 24, 2018
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into sqlalchemy-utils-types
parents
0fefc1c8
519ab4d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
7 deletions
+14
-7
app.py
examples/sqla/app.py
+9
-1
requirements.txt
examples/sqla/requirements.txt
+1
-0
base.py
flask_admin/model/base.py
+2
-2
actions.js
flask_admin/static/admin/js/actions.js
+2
-4
No files found.
examples/sqla/app.py
View file @
5066d6d2
...
...
@@ -57,6 +57,9 @@ class User(db.Model):
def
__str__
(
self
):
return
"{}, {}"
.
format
(
self
.
last_name
,
self
.
first_name
)
def
__repr__
(
self
):
return
"{}: {}"
.
format
(
self
.
id
,
self
.
__str__
())
class
Pet
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
...
...
@@ -159,6 +162,7 @@ inline_form_options = {
}
class
UserAdmin
(
sqla
.
ModelView
):
action_disallowed_list
=
[
'delete'
,
]
column_display_pk
=
True
column_list
=
[
'id'
,
...
...
@@ -202,9 +206,10 @@ class UserAdmin(sqla.ModelView):
# Customized Post model admin
class
PostAdmin
(
sqla
.
ModelView
):
column_
exclude_list
=
[
'text
'
]
column_
list
=
[
'id'
,
'user'
,
'title'
,
'date'
,
'tags
'
]
column_default_sort
=
(
'date'
,
True
)
column_sortable_list
=
[
'id'
,
'title'
,
'date'
,
(
'user'
,
(
'user.last_name'
,
'user.first_name'
)),
# sort on multiple columns
...
...
@@ -223,6 +228,9 @@ class PostAdmin(sqla.ModelView):
'tags'
,
filters
.
FilterLike
(
Post
.
title
,
'Fixed Title'
,
options
=
((
'test1'
,
'Test 1'
),
(
'test2'
,
'Test 2'
))),
]
can_export
=
True
export_max_rows
=
1000
export_types
=
[
'csv'
,
'xls'
]
# Pass arguments to WTForms. In this case, change label for text field to
# be 'Big Text' and add required() validator.
...
...
examples/sqla/requirements.txt
View file @
5066d6d2
Flask
Flask-Admin
Flask-SQLAlchemy
tablib
flask_admin/model/base.py
View file @
5066d6d2
...
...
@@ -2330,12 +2330,12 @@ class BaseModelView(BaseView, ActionsMixin):
if
encoding
:
mimetype
=
'
%
s; charset=
%
s'
%
(
mimetype
,
encoding
)
ds
=
tablib
.
Dataset
(
headers
=
[
c
[
1
]
for
c
in
self
.
_export_columns
])
ds
=
tablib
.
Dataset
(
headers
=
[
c
sv_encode
(
c
[
1
])
for
c
in
self
.
_export_columns
])
count
,
data
=
self
.
_export_data
()
for
row
in
data
:
vals
=
[
self
.
get_export_value
(
row
,
c
[
0
]
)
for
c
in
self
.
_export_columns
]
vals
=
[
csv_encode
(
self
.
get_export_value
(
row
,
c
[
0
])
)
for
c
in
self
.
_export_columns
]
ds
.
append
(
vals
)
try
:
...
...
flask_admin/static/admin/js/actions.js
View file @
5066d6d2
var
AdminModelActions
=
function
(
actionErrorMessage
,
actionConfirmations
)
{
//
Actions helpers. TODO: Move to separate file
//
batch actions helpers
this
.
execute
=
function
(
name
)
{
var
selected
=
$
(
'input.action-checkbox:checked'
).
length
;
...
...
@@ -48,6 +48,4 @@ var AdminModelActions = function(actionErrorMessage, actionConfirmations) {
});
});
};
if
(
$
(
'#actions_confirmation'
).
length
==
1
)
{
var
modelActions
=
new
AdminModelActions
(
JSON
.
parse
(
$
(
'#message-data'
).
text
()),
JSON
.
parse
(
$
(
'#actions-confirmation-data'
).
text
()));
}
var
modelActions
=
new
AdminModelActions
(
JSON
.
parse
(
$
(
'#message-data'
).
text
()),
JSON
.
parse
(
$
(
'#actions-confirmation-data'
).
text
()));
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