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
313b826e
Commit
313b826e
authored
Apr 10, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Translation fixes.
parent
ee46f523
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
366 additions
and
33 deletions
+366
-33
MANIFEST.in
MANIFEST.in
+1
-0
TODO.txt
TODO.txt
+3
-0
admin.pot
babel/admin.pot
+225
-0
babel.bat
babel/babel.bat
+1
-0
babel.ini
babel/babel.ini
+5
-0
babel.sh
babel/babel.sh
+2
-0
babel.py
flask_adminex/babel.py
+75
-29
base.py
flask_adminex/base.py
+51
-1
filters.py
flask_adminex/model/filters.py
+1
-1
lib.html
flask_adminex/templates/admin/lib.html
+1
-1
create.html
flask_adminex/templates/admin/model/create.html
+1
-1
No files found.
MANIFEST.in
View file @
313b826e
include LICENSE
recursive-include flask_adminex/static *
recursive-include flask_adminex/templates *
recursive-include flask_adminex/translations *
TODO.txt
View file @
313b826e
- Core
- View Site button?
- Localization
- Verify that babel string collection works
- Add localized sample
- Model Admin
- Reduce number of parameters passed to list view
- Checkboxes and mass operations
- Filters
- Custom filters for date fields?
- Change boolean filter to True/False instead of Yes/No
- Ability to sort by fields that are not visible?
- List display callables?
- SQLA Model Admin
...
...
babel/admin.pot
0 → 100644
View file @
313b826e
# Translations template for Flask-AdminEx.
# Copyright (C) 2012 ORGANIZATION
# This file is distributed under the same license as the Flask-AdminEx
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Flask-AdminEx VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2012-04-10 23:45+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
#: ../flask_adminex/form.py:81
msgid "Invalid time format"
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:32
msgid "Invalid directory name"
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:49
msgid "File required."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:54
msgid "Invalid file type."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:335
msgid "File uploading is disabled."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:344
#, python-format
msgid "File \"%(name)s\" already exists."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:351
#, python-format
msgid "Failed to save file: %(error)s"
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:370
msgid "Directory creation is disabled."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:380
#, python-format
msgid "Failed to create directory: %(error)s"
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:402
msgid "Deletion is disabled."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:407
msgid "Directory deletion is disabled."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:412
#, python-format
msgid "Directory \"%s\" was successfully deleted."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:414
#, python-format
msgid "Failed to delete directory: %(error)s"
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:418
#, python-format
msgid "File \"%(name)s\" was successfully deleted."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:420
#, python-format
msgid "Failed to delete file: %(name)s"
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:439
msgid "Renaming is disabled."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:443
msgid "Path does not exist."
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:454
#, python-format
msgid "Successfully renamed \"%(src)s\" to \"%(dst)s\""
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:457
#, python-format
msgid "Failed to rename: %(error)s"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:35
msgid "equals"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:43
msgid "not equal"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:52
msgid "contains"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:61
msgid "not contains"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:69
msgid "greater than"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:77
msgid "smaller than"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/form.py:37
msgid "Already exists."
msgstr ""
#: ../flask_adminex/ext/sqlamodel/view.py:504
#, python-format
msgid "Failed to create model. %(error)s"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/view.py:519
#, python-format
msgid "Failed to update model. %(error)s"
msgstr ""
#: ../flask_adminex/ext/sqlamodel/view.py:534
#, python-format
msgid "Failed to delete model. %(error)s"
msgstr ""
#: ../flask_adminex/model/base.py:742
msgid "Model was successfully created."
msgstr ""
#: ../flask_adminex/templates/admin/lib.html:105
msgid "Submit"
msgstr ""
#: ../flask_adminex/templates/admin/lib.html:110
msgid "Cancel"
msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:7
msgid "Root"
msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:42
#, python-format
msgid "Are you sure you want to delete \\'%(name)s\\' recursively?"
msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:50
#, python-format
msgid "Are you sure you want to delete \\'%(name)s\\'?"
msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:75
msgid "Upload File"
msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:78
msgid "Create Directory"
msgstr ""
#: ../flask_adminex/templates/admin/file/rename.html:5
#, python-format
msgid "Please provide new name for %(name)s"
msgstr ""
#: ../flask_adminex/templates/admin/model/create.html:11
msgid "Save and Add"
msgstr ""
#: ../flask_adminex/templates/admin/model/create.html:16
#: ../flask_adminex/templates/admin/model/list.html:12
msgid "List"
msgstr ""
#: ../flask_adminex/templates/admin/model/create.html:19
#: ../flask_adminex/templates/admin/model/list.html:16
msgid "Create"
msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:23
msgid "Add Filter"
msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:44
msgid "Search"
msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:57
msgid "Apply"
msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:59
msgid "Reset Filters"
msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:67
msgid "Remove Filter"
msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:128
msgid "You sure you want to delete this item?"
msgstr ""
babel/babel.bat
0 → 100644
View file @
313b826e
pybabel extract -F babel.ini -k _gettext -k _ngettext -o admin.pot --project Flask-AdminEx ..\flask_adminex
babel/babel.ini
0 → 100644
View file @
313b826e
# Python
[python: **.py]
# Jinja2
[jinja2: **/templates/**.html]
encoding
=
utf-8
babel/babel.sh
0 → 100644
View file @
313b826e
#!/bin/sh
pybabel extract
-F
babel.ini
-k
_gettext
-k
_ngettext
-o
admin.pot
--project
Flask-AdminEx ../flask_adminex
flask_adminex/babel.py
View file @
313b826e
from
__future__
import
absolute_import
import
os.path
as
op
from
flask
import
_request_ctx_stack
def
_gettext
(
string
,
**
variables
):
return
string
%
variables
try
:
from
babel
import
support
,
Locale
from
speaklater
import
make_lazy_string
class
Namespace
(
object
):
def
__init__
(
self
,
dirname
=
None
,
namespace
=
''
,
default_locale
=
'en'
):
self
.
dirname
=
dirname
self
.
namespace
=
namespace
self
.
default_locale
=
Locale
.
parse
(
default_locale
)
def
_ngettext
(
singular
,
plural
,
num
,
**
variables
):
return
(
singular
if
num
==
1
else
plural
)
%
variables
def
_get_locale
(
self
):
ctx
=
_request_ctx_stack
.
top
if
ctx
is
None
:
return
None
locale
=
getattr
(
ctx
,
'admin_locale'
,
None
)
if
locale
is
None
:
admin
=
ctx
.
app
.
extensions
[
'admin'
]
def
_lazy_gettext
(
string
,
**
variables
)
:
return
string
%
variables
if
admin
.
locale_selector_func
:
locale_name
=
admin
.
locale_selector_func
()
# Wrap flask-babel API
try
:
from
flask.ext
import
babel
if
locale_name
:
locale
=
Locale
.
parse
(
locale_name
)
else
:
locale
=
self
.
default_locale
else
:
locale
=
self
.
default_locale
ctx
.
admin_locale
=
locale
return
locale
def
_is_babel_on
(
):
def
_get_translations
(
self
):
ctx
=
_request_ctx_stack
.
top
if
ctx
is
None
:
return
Fals
e
return
Non
e
return
hasattr
(
ctx
,
'babel_locale'
)
attr
=
'admin_trans_'
+
self
.
namespace
def
gettext
(
string
,
**
variables
):
if
not
_is_babel_on
():
return
_gettext
(
string
,
**
variables
)
translations
=
getattr
(
ctx
,
attr
,
None
)
if
translations
is
None
:
dirname
=
self
.
dirname
or
op
.
join
(
ctx
.
app
.
root_path
,
'translations'
)
translations
=
support
.
Translations
.
load
(
dirname
,
[
self
.
_get_locale
()],
domain
=
self
.
namespace
)
setattr
(
ctx
,
attr
,
translations
)
return
babel
.
gettext
(
string
,
**
variables
)
return
translations
def
ngettext
(
singular
,
plural
,
num
,
**
variables
):
if
not
_is_babel_on
():
return
_ngettext
(
singular
,
plural
,
num
,
**
variables
)
def
gettext
(
self
,
string
,
**
variables
):
translations
=
self
.
_get_translations
()
return
translations
.
ugettext
(
string
,
**
variables
)
return
babel
.
ngettext
(
singular
,
plural
,
num
,
**
variables
)
def
ngettext
(
self
,
singular
,
plural
,
num
,
**
variables
):
translations
=
self
.
_get_translations
()
return
translations
.
ungettext
(
singular
,
plural
,
num
,
**
variables
)
def
lazy_gettext
(
string
,
**
variables
):
from
speaklater
import
make_lazy_string
return
make_lazy_string
(
gettext
,
string
,
**
variables
)
def
lazy_gettext
(
self
,
string
,
**
variables
):
return
make_lazy_string
(
self
.
gettext
,
string
,
**
variables
)
except
ImportError
,
ex
:
class
DummyNamespace
(
object
):
def
__init__
(
self
,
dirname
=
None
,
namespace
=
'admin'
):
self
.
dirname
=
dirname
self
.
namespace
=
namespace
def
gettext
(
self
,
string
,
**
variables
):
return
string
%
variables
def
ngettext
(
self
,
singular
,
plural
,
num
,
**
variables
):
return
(
singular
if
num
==
1
else
plural
)
%
variables
def
lazy_gettext
(
self
,
string
,
**
variables
):
return
string
%
variables
Namespace
=
DummyNamespace
# Create default namespace pointing to the flask-adminex localization directory
ns
=
Namespace
(
namespace
=
'admin'
)
except
ImportError
:
gettext
=
_
gettext
ngettext
=
_
ngettext
lazy_gettext
=
_
lazy_gettext
# Create shortcuts for default namespace
gettext
=
ns
.
gettext
ngettext
=
ns
.
ngettext
lazy_gettext
=
ns
.
lazy_gettext
flask_adminex/base.py
View file @
313b826e
...
...
@@ -283,6 +283,8 @@ class Admin(object):
`index_view`
Home page view to use. If not provided, will use `AdminIndexView`.
"""
self
.
app
=
app
self
.
_views
=
[]
self
.
_menu
=
[]
self
.
_menu_categories
=
dict
()
...
...
@@ -295,15 +297,21 @@ class Admin(object):
url
=
'/admin'
self
.
url
=
url
# Localizations
self
.
locale_selector_func
=
None
# Index view
if
index_view
is
None
:
index_view
=
AdminIndexView
(
url
=
self
.
url
)
self
.
app
=
app
self
.
index_view
=
index_view
# Add predefined index view
self
.
add_view
(
index_view
)
if
app
:
self
.
_init_extension
()
def
add_view
(
self
,
view
):
"""
Add view to the collection.
...
...
@@ -319,6 +327,37 @@ class Admin(object):
self
.
app
.
register_blueprint
(
view
.
create_blueprint
(
self
))
self
.
_add_view_to_menu
(
view
)
def
locale_selector
(
self
,
f
):
"""
Install locale selector for current admin instance.
Example::
admin = Admin(app)
@admin.locale_selector
def admin_locale_selector():
return request.args.get('lang', 'en')
Another example:
def admin_locale_selector():
return request.args.get('lang', 'en')
admin = Admin(app)
admin.locale_selector(admin_locale_selector)
And if you want to subclass ``Admin``, you can do something like:
class MyAdmin(Admin):
def locale_selector(self):
return request.args.get('lang', 'en')
"""
if
self
.
locale_selector_func
is
not
None
:
raise
Exception
(
'Can not add locale_selector second time.'
)
self
.
locale_selector_func
=
f
def
_add_view_to_menu
(
self
,
view
):
"""
Add view to the menu tree
...
...
@@ -354,6 +393,17 @@ class Admin(object):
app
.
register_blueprint
(
view
.
create_blueprint
(
self
))
self
.
_add_view_to_menu
(
view
)
self
.
_init_extension
()
def
_init_extension
(
self
):
if
not
hasattr
(
self
.
app
,
'extensions'
):
self
.
app
.
extensions
=
dict
()
if
'admin'
in
self
.
app
.
extensions
:
raise
Exception
(
'Can not have more than one instance of the Admin class associated with Flask application'
)
self
.
app
.
extensions
[
'admin'
]
=
self
def
menu
(
self
):
"""
Return menu hierarchy.
...
...
flask_adminex/model/filters.py
View file @
313b826e
from
flask.ext.babel
import
lazy_gettext
from
flask.ext.
adminex.
babel
import
lazy_gettext
class
BaseFilter
(
object
):
...
...
flask_adminex/templates/admin/lib.html
View file @
313b826e
...
...
@@ -102,7 +102,7 @@
{% endfor %}
<div
class=
"control-group"
>
<div
class=
"controls"
>
<input
type=
"submit"
class=
"btn btn-primary btn-large"
/>
<input
type=
"submit"
class=
"btn btn-primary btn-large"
value=
"{{ _gettext('Submit') }}"
/>
{% if extra %}
{{ extra }}
{% endif %}
...
...
flask_adminex/templates/admin/model/create.html
View file @
313b826e
...
...
@@ -13,7 +13,7 @@
<ul
class=
"nav nav-tabs"
>
<li>
<a
href=
"{{ return_url }}"
>
List
</a>
<a
href=
"{{ return_url }}"
>
{{ _gettext('List') }}
</a>
</li>
<li
class=
"active"
>
<a
href=
"#"
>
{{ _gettext('Create') }}
</a>
...
...
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