Commit 73256448 authored by mrjoes's avatar mrjoes

Cleaned up code a bit

parent b6541d53
# Translations template for Flask-AdminEx. # Translations template for Flask-Admin.
# Copyright (C) 2012 ORGANIZATION # Copyright (C) 2012 ORGANIZATION
# This file is distributed under the same license as the Flask-AdminEx # This file is distributed under the same license as the Flask-Admin
# project. # project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012. # FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
# #
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Flask-AdminEx VERSION\n" "Project-Id-Version: Flask-Admin VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2012-04-11 18:47+0300\n" "POT-Creation-Date: 2012-08-19 10:04+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -18,224 +18,248 @@ msgstr "" ...@@ -18,224 +18,248 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n" "Generated-By: Babel 0.9.6\n"
#: ../flask_adminex/base.py:216 #: ../flask_admin/base.py:217
msgid "Home" msgid "Home"
msgstr "" msgstr ""
#: ../flask_adminex/form.py:81 #: ../flask_admin/form.py:81
msgid "Invalid time format" msgid "Invalid time format"
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:32 #: ../flask_admin/contrib/fileadmin.py:32
msgid "Invalid directory name" msgid "Invalid directory name"
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:40 #: ../flask_admin/contrib/fileadmin.py:40
msgid "File to upload" msgid "File to upload"
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:49 #: ../flask_admin/contrib/fileadmin.py:49
msgid "File required." msgid "File required."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:54 #: ../flask_admin/contrib/fileadmin.py:54
msgid "Invalid file type." msgid "Invalid file type."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:335 #: ../flask_admin/contrib/fileadmin.py:338
msgid "File uploading is disabled." msgid "File uploading is disabled."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:344 #: ../flask_admin/contrib/fileadmin.py:347
#, python-format #, python-format
msgid "File \"%(name)s\" already exists." msgid "File \"%(name)s\" already exists."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:351 #: ../flask_admin/contrib/fileadmin.py:354
#, python-format #, python-format
msgid "Failed to save file: %(error)s" msgid "Failed to save file: %(error)s"
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:370 #: ../flask_admin/contrib/fileadmin.py:373
msgid "Directory creation is disabled." msgid "Directory creation is disabled."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:380 #: ../flask_admin/contrib/fileadmin.py:383
#, python-format #, python-format
msgid "Failed to create directory: %(error)s" msgid "Failed to create directory: %(error)s"
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:402 #: ../flask_admin/contrib/fileadmin.py:405
msgid "Deletion is disabled." msgid "Deletion is disabled."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:407 #: ../flask_admin/contrib/fileadmin.py:410
msgid "Directory deletion is disabled." msgid "Directory deletion is disabled."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:412 #: ../flask_admin/contrib/fileadmin.py:415
#, python-format #, python-format
msgid "Directory \"%s\" was successfully deleted." msgid "Directory \"%s\" was successfully deleted."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:414 #: ../flask_admin/contrib/fileadmin.py:417
#, python-format #, python-format
msgid "Failed to delete directory: %(error)s" msgid "Failed to delete directory: %(error)s"
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:418 #: ../flask_admin/contrib/fileadmin.py:421
#, python-format #, python-format
msgid "File \"%(name)s\" was successfully deleted." msgid "File \"%(name)s\" was successfully deleted."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:420 #: ../flask_admin/contrib/fileadmin.py:423
#, python-format #, python-format
msgid "Failed to delete file: %(name)s" msgid "Failed to delete file: %(name)s"
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:439 #: ../flask_admin/contrib/fileadmin.py:442
msgid "Renaming is disabled." msgid "Renaming is disabled."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:443 #: ../flask_admin/contrib/fileadmin.py:446
msgid "Path does not exist." msgid "Path does not exist."
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:454 #: ../flask_admin/contrib/fileadmin.py:457
#, python-format #, python-format
msgid "Successfully renamed \"%(src)s\" to \"%(dst)s\"" msgid "Successfully renamed \"%(src)s\" to \"%(dst)s\""
msgstr "" msgstr ""
#: ../flask_adminex/ext/fileadmin.py:457 #: ../flask_admin/contrib/fileadmin.py:460
#, python-format #, python-format
msgid "Failed to rename: %(error)s" msgid "Failed to rename: %(error)s"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:35 #: ../flask_admin/contrib/sqlamodel/filters.py:35
msgid "equals" msgid "equals"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:43 #: ../flask_admin/contrib/sqlamodel/filters.py:43
msgid "not equal" msgid "not equal"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:52 #: ../flask_admin/contrib/sqlamodel/filters.py:52
msgid "contains" msgid "contains"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:61 #: ../flask_admin/contrib/sqlamodel/filters.py:61
msgid "not contains" msgid "not contains"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:69 #: ../flask_admin/contrib/sqlamodel/filters.py:69
msgid "greater than" msgid "greater than"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/filters.py:77 #: ../flask_admin/contrib/sqlamodel/filters.py:77
msgid "smaller than" msgid "smaller than"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/form.py:37 #: ../flask_admin/contrib/sqlamodel/form.py:37
msgid "Already exists." msgid "Already exists."
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/view.py:504 #: ../flask_admin/contrib/sqlamodel/view.py:520
#, python-format #, python-format
msgid "Failed to create model. %(error)s" msgid "Failed to create model. %(error)s"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/view.py:519 #: ../flask_admin/contrib/sqlamodel/view.py:535
#, python-format #, python-format
msgid "Failed to update model. %(error)s" msgid "Failed to update model. %(error)s"
msgstr "" msgstr ""
#: ../flask_adminex/ext/sqlamodel/view.py:534 #: ../flask_admin/contrib/sqlamodel/view.py:550
#, python-format #, python-format
msgid "Failed to delete model. %(error)s" msgid "Failed to delete model. %(error)s"
msgstr "" msgstr ""
#: ../flask_adminex/model/base.py:742 #: ../flask_admin/contrib/sqlamodel/view.py:561
msgid "delete"
msgstr ""
#: ../flask_admin/contrib/sqlamodel/view.py:573
#, python-format
msgid "Model was successfully deleted."
msgid_plural "%(count)s models were sucessfully deleted."
msgstr[0] ""
msgstr[1] ""
#: ../flask_admin/contrib/sqlamodel/view.py:578
#, python-format
msgid "Failed to delete models. %(error)s"
msgstr ""
#: ../flask_admin/model/base.py:784
msgid "Model was successfully created." msgid "Model was successfully created."
msgstr "" msgstr ""
#: ../flask_adminex/model/filters.py:82 #: ../flask_admin/model/filters.py:82
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
#: ../flask_adminex/model/filters.py:83 #: ../flask_admin/model/filters.py:83
msgid "No" msgid "No"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/lib.html:105 #: ../flask_admin/templates/admin/lib.html:108
msgid "Submit" msgid "Submit"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/lib.html:110 #: ../flask_admin/templates/admin/lib.html:113
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:7 #: ../flask_admin/templates/admin/file/list.html:7
msgid "Root" msgid "Root"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:42 #: ../flask_admin/templates/admin/file/list.html:42
#, python-format #, python-format
msgid "Are you sure you want to delete \\'%(name)s\\' recursively?" msgid "Are you sure you want to delete \\'%(name)s\\' recursively?"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:50 #: ../flask_admin/templates/admin/file/list.html:50
#, python-format #, python-format
msgid "Are you sure you want to delete \\'%(name)s\\'?" msgid "Are you sure you want to delete \\'%(name)s\\'?"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:75 #: ../flask_admin/templates/admin/file/list.html:75
msgid "Upload File" msgid "Upload File"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/file/list.html:78 #: ../flask_admin/templates/admin/file/list.html:78
msgid "Create Directory" msgid "Create Directory"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/file/rename.html:5 #: ../flask_admin/templates/admin/file/rename.html:5
#, python-format #, python-format
msgid "Please provide new name for %(name)s" msgid "Please provide new name for %(name)s"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/create.html:11 #: ../flask_admin/templates/admin/model/create.html:11
msgid "Save and Add" msgid "Save and Add"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/create.html:16 #: ../flask_admin/templates/admin/model/create.html:16
#: ../flask_adminex/templates/admin/model/list.html:12 #: ../flask_admin/templates/admin/model/list.html:12
msgid "List" msgid "List"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/create.html:19 #: ../flask_admin/templates/admin/model/create.html:19
#: ../flask_adminex/templates/admin/model/list.html:16 #: ../flask_admin/templates/admin/model/list.html:16
msgid "Create" msgid "Create"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:23 #: ../flask_admin/templates/admin/model/list.html:23
msgid "Add Filter" msgid "Add Filter"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:44 #: ../flask_admin/templates/admin/model/list.html:38
msgid "With selected"
msgstr ""
#: ../flask_admin/templates/admin/model/list.html:59
msgid "Search" msgid "Search"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:57 #: ../flask_admin/templates/admin/model/list.html:72
msgid "Apply" msgid "Apply"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:59 #: ../flask_admin/templates/admin/model/list.html:74
msgid "Reset Filters" msgid "Reset Filters"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:67 #: ../flask_admin/templates/admin/model/list.html:82
msgid "Remove Filter" msgid "Remove Filter"
msgstr "" msgstr ""
#: ../flask_adminex/templates/admin/model/list.html:128 #: ../flask_admin/templates/admin/model/list.html:153
msgid "You sure you want to delete this item?" msgid "You sure you want to delete this item?"
msgstr "" msgstr ""
#: ../flask_admin/templates/admin/model/list.html:211
msgid "Please select at least one model."
msgstr ""
...@@ -6,7 +6,7 @@ from wtforms.ext.sqlalchemy.orm import model_form ...@@ -6,7 +6,7 @@ from wtforms.ext.sqlalchemy.orm import model_form
from flask import flash from flask import flash
from flask.ext.admin.babel import gettext, ngettext from flask.ext.admin.babel import gettext, ngettext, lazy_gettext
from flask.ext.admin.form import BaseForm from flask.ext.admin.form import BaseForm
from flask.ext.admin.model import BaseModelView, action from flask.ext.admin.model import BaseModelView, action
...@@ -558,7 +558,9 @@ class ModelView(BaseModelView): ...@@ -558,7 +558,9 @@ class ModelView(BaseModelView):
return super(ModelView, self).is_action_allowed(name) return super(ModelView, self).is_action_allowed(name)
@action('delete', 'Delete', 'Are you sure you want to delete selected models?') @action('delete',
lazy_gettext('Delete'),
lazy_gettext('Are you sure you want to delete selected models?'))
def action_delete(self, ids): def action_delete(self, ids):
try: try:
model_pk = getattr(self.model, self._primary_key) model_pk = getattr(self.model, self._primary_key)
......
...@@ -715,13 +715,18 @@ class BaseModelView(BaseView): ...@@ -715,13 +715,18 @@ class BaseModelView(BaseView):
return self._get_url('.index_view', page, column, desc, return self._get_url('.index_view', page, column, desc,
search, filters) search, filters)
# Actions # Actions.
actions = filter(lambda x: self.is_action_allowed(x[0]), self._actions) actions = []
actions_confirmation = {}
for act in self._actions:
name, text = act
if self.is_action_allowed(name):
text = unicode(text)
actions_confirmation = dict() actions.append((name, text))
for act in actions: actions_confirmation[name] = unicode(self._action_data[name][2])
name, _ = act
actions_confirmation[name] = gettext(self._action_data[name][2])
return self.render(self.list_template, return self.render(self.list_template,
data=data, data=data,
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<ul id="action_list" class="dropdown-menu"> <ul id="action_list" class="dropdown-menu">
{% for p in actions %} {% for p in actions %}
<li> <li>
<a href="#" onclick="return actionExecute('{{ p[0] }}');">{{ _gettext(p[1]) }}</a> <a href="#" onclick="return modelActions.execute('{{ p[0] }}');">{{ _gettext(p[1]) }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
<tr> <tr>
{% if actions %} {% if actions %}
<td> <td>
<input type="checkbox" name="rowid" value="{{ get_pk_value(row) }}" /> <input type="checkbox" name="rowid" class="action-checkbox" value="{{ get_pk_value(row) }}" />
</td> </td>
{% endif %} {% endif %}
<td> <td>
...@@ -177,6 +177,13 @@ ...@@ -177,6 +177,13 @@
<script src="{{ url_for('admin.static', filename='js/bootstrap-datepicker.js') }}"></script> <script src="{{ url_for('admin.static', filename='js/bootstrap-datepicker.js') }}"></script>
<script src="{{ url_for('admin.static', filename='js/form.js') }}"></script> <script src="{{ url_for('admin.static', filename='js/form.js') }}"></script>
<script src="{{ url_for('admin.static', filename='js/filters.js') }}"></script> <script src="{{ url_for('admin.static', filename='js/filters.js') }}"></script>
{% if actions %}
<script src="{{ url_for('admin.static', filename='js/actions.js') }}"></script>
<script language="javascript">
var modelActions = new AdminModelActions('{{ _gettext("Please select at least one model.") }}',
{{ actions_confirmation|tojson|safe }});
</script>
{% endif %}
{% if filter_groups is not none and filter_data is not none %} {% if filter_groups is not none and filter_data is not none %}
<script language="javascript"> <script language="javascript">
var form = new AdminForm(); var form = new AdminForm();
...@@ -184,45 +191,6 @@ ...@@ -184,45 +191,6 @@
{{ admin_view._filter_dict|tojson|safe }}, {{ admin_view._filter_dict|tojson|safe }},
{{ filter_data|tojson|safe }}, {{ filter_data|tojson|safe }},
{{ filter_types|tojson|safe }}); {{ filter_types|tojson|safe }});
// Actions helpers. TODO: Move to separate file
$(function() {
$('#rowtoggle').change(function() {
$('td input[type=checkbox]').attr('checked', this.checked);
});
var actionForm = $('#action_form');
actionForm.submit(function() {
$('td input[type=checkbox]:checked').each(function() {
actionForm.append($(this).clone());
});
});
});
// TODO: Cleanup this mess
var confirmation = {{ actions_confirmation|tojson|safe }};
function actionExecute(name) {
var selected = $('td input[type=checkbox]:checked').size();
if (selected == 0)
{
// TODO: Translation
alert('{{ _gettext("Please select at least one model.") }}');
return false;
}
var msg = confirmation[$('#action_form select').val()];
if (!!msg)
if (!confirm(msg))
return false;
$('#action_form #action').val(name);
$('#action_form').submit();
return false;
}
</script> </script>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment