Add delete confirmation and fix babel

This commit is contained in:
Ainur Timerbaev
2024-08-28 10:28:56 +01:00
parent 66b69c29fc
commit 3a046cc16c
7 changed files with 143 additions and 115 deletions

View File

@ -1,3 +1,3 @@
[python: fastapi_admin/**.py]
[jinja2: fastapi_admin/templates/**.html]
extensions = jinja2.ext.i18n,jinja2.ext.autoescape
extensions = jinja2.ext.i18n

View File

@ -7,16 +7,16 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-08-06 23:07+0800\n"
"POT-Creation-Date: 2024-08-28 10:24+0100\n"
"PO-Revision-Date: 2021-04-16 22:46+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
"Generated-By: Babel 2.14.0\n"
#: fastapi_admin/resources.py:91
msgid "create"
@ -115,27 +115,32 @@ msgstr "Search"
msgid "bulk_actions"
msgstr "Bulk Actions"
#: fastapi_admin/templates/list.html:125
#: fastapi_admin/templates/list.html:139
msgid "actions"
msgstr "Actions"
#: fastapi_admin/templates/list.html:156
#: fastapi_admin/templates/list.html:170
#, python-format
msgid "Showing %(from)s to %(to)s of %(total)s entries"
msgstr ""
#: fastapi_admin/templates/list.html:167
#: fastapi_admin/templates/list.html:181
msgid "prev_page"
msgstr "Prev"
#: fastapi_admin/templates/list.html:188
#: fastapi_admin/templates/list.html:202
msgid "next_page"
msgstr "Next"
#: fastapi_admin/templates/list.html:214
msgid "delete_confirmation"
msgstr "Are you sure want to delete this item?"
#: fastapi_admin/templates/update.html:23
msgid "save_and_return"
msgstr "Save and return"
#: fastapi_admin/templates/errors/401.html:21
#: fastapi_admin/templates/errors/403.html:21
#: fastapi_admin/templates/errors/404.html:21
#: fastapi_admin/templates/errors/500.html:21

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-02-21 12:21-0300\n"
"POT-Creation-Date: 2024-08-28 10:24+0100\n"
"PO-Revision-Date: 2024-02-21 12:22-0300\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: es_PY\n"
@ -18,86 +18,49 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"
#: fastapi_admin/middlewares.py:77
#, python-format
msgid "You can only try after %(seconds)s seconds"
msgstr "Solo puedes intentarlo después de %(seconds)s segundos"
#: fastapi_admin/middlewares.py:88
#, python-format
msgid "Login failed %(times)s times, you can try %(rest_times)s more times"
msgstr "Fallo en el inicio de sesión %(times)s veces, puedes intentarlo %(rest_times)s veces más"
#: fastapi_admin/resources.py:120
#: fastapi_admin/resources.py:91
msgid "create"
msgstr "Agregar nuevo"
#: fastapi_admin/resources.py:132
#: fastapi_admin/resources.py:112
msgid "update"
msgstr "Editar"
#: fastapi_admin/resources.py:139
#: fastapi_admin/resources.py:114
msgid "delete"
msgstr "Borrar"
#: fastapi_admin/resources.py:149
#: fastapi_admin/resources.py:120
msgid "delete_selected"
msgstr "Eliminar seleccionados"
#: fastapi_admin/providers/import_export.py:106
#: fastapi_admin/templates/providers/import_export/import.html:6
#: fastapi_admin/templates/providers/import_export/import.html:30
msgid "Import"
msgstr "Importar"
#: fastapi_admin/providers/import_export.py:117
#: fastapi_admin/templates/providers/import_export/export.html:6
#: fastapi_admin/templates/providers/import_export/export.html:23
msgid "Export"
msgstr "Exportar"
#: fastapi_admin/providers/import_export.py:176
#, python-format
msgid "Success create %(count)s %(label)s"
msgstr "Éxito al crear %(count)s %(label)s"
#: fastapi_admin/providers/login.py:136
msgid "captcha_error"
msgstr "Error en el captcha"
#: fastapi_admin/providers/login.py:153
msgid "Google recaptcha verify failed"
msgstr "La verificación de Google reCAPTCHA falló"
#: fastapi_admin/providers/login.py:160
#: fastapi_admin/providers/login.py:90
msgid "login_failed"
msgstr "Fallo en el inicio de sesión"
#: fastapi_admin/providers/login.py:234
#: fastapi_admin/providers/login.py:161
msgid "confirm_password_different"
msgstr "Las contraseñas no coinciden"
#: fastapi_admin/providers/login.py:269
#: fastapi_admin/providers/login.py:196
msgid "old_password_error"
msgstr "Error en la contraseña antigua"
#: fastapi_admin/providers/login.py:271
#: fastapi_admin/providers/login.py:198
msgid "new_password_different"
msgstr "La nueva contraseña no coincide"
#: fastapi_admin/templates/create.html:15
#: fastapi_admin/templates/update.html:17
#: fastapi_admin/templates/create.html:14
#: fastapi_admin/templates/update.html:16
msgid "save"
msgstr "Guardar"
#: fastapi_admin/templates/create.html:17
#: fastapi_admin/templates/create.html:16
msgid "save_and_add_another"
msgstr "Guardar y agregar otro"
#: fastapi_admin/templates/create.html:19
#: fastapi_admin/templates/providers/import_export/export.html:25
#: fastapi_admin/templates/providers/import_export/import.html:32
#: fastapi_admin/templates/update.html:27
#: fastapi_admin/templates/create.html:18
#: fastapi_admin/templates/update.html:29
msgid "return"
msgstr "Volver"
@ -106,22 +69,20 @@ msgid "Create first admin"
msgstr "Crear primer administrador"
#: fastapi_admin/templates/init.html:12
#: fastapi_admin/templates/providers/login/login.html:17
#: fastapi_admin/templates/providers/login/login.html:44
msgid "username"
msgstr "Nombre de usuario"
#: fastapi_admin/templates/init.html:14
#: fastapi_admin/templates/providers/login/login.html:19
msgid "username_placeholder"
msgstr "Ingrese el nombre de usuario"
#: fastapi_admin/templates/init.html:18
#: fastapi_admin/templates/providers/login/login.html:23
#: fastapi_admin/templates/providers/login/login.html:54
msgid "password"
msgstr "Contraseña"
#: fastapi_admin/templates/init.html:23
#: fastapi_admin/templates/providers/login/login.html:28
msgid "password_placeholder"
msgstr "Ingrese la contraseña"
@ -154,24 +115,28 @@ msgstr "Buscar"
msgid "bulk_actions"
msgstr "Acciones masivas"
#: fastapi_admin/templates/list.html:127
#: fastapi_admin/templates/list.html:139
msgid "actions"
msgstr "Acciones"
#: fastapi_admin/templates/list.html:158
#: fastapi_admin/templates/list.html:170
#, python-format
msgid "Showing %(from)s to %(to)s of %(total)s entries"
msgstr "Mostrando %(from)s a %(to)s de %(total)s entradas"
#: fastapi_admin/templates/list.html:169
#: fastapi_admin/templates/list.html:181
msgid "prev_page"
msgstr "Pág. Anterior"
#: fastapi_admin/templates/list.html:190
#: fastapi_admin/templates/list.html:202
msgid "next_page"
msgstr "Pág. Siguiente"
#: fastapi_admin/templates/update.html:24
#: fastapi_admin/templates/list.html:214
msgid "delete_confirmation"
msgstr "¿Estás seguro de que quieres eliminar este artículo?"
#: fastapi_admin/templates/update.html:23
msgid "save_and_return"
msgstr "Guardar y volver"
@ -182,37 +147,30 @@ msgstr "Guardar y volver"
msgid "return_home"
msgstr "Volver a inicio"
#: fastapi_admin/templates/providers/import_export/export.html:11
#: fastapi_admin/templates/providers/import_export/import.html:18
msgid "Format"
msgstr "Formato"
#: fastapi_admin/templates/providers/import_export/import.html:14
msgid "File to import"
msgstr "Archivo a importar"
#: fastapi_admin/templates/providers/login/avatar.html:20
#: fastapi_admin/templates/providers/login/avatar.html:18
#: fastapi_admin/templates/providers/login/password.html:6
msgid "update_password"
msgstr "Actualizar contraseña"
#: fastapi_admin/templates/providers/login/avatar.html:23
#: fastapi_admin/templates/providers/login/avatar.html:24
msgid "logout"
msgstr "Cerrar sesión"
#: fastapi_admin/templates/providers/login/login.html:37
msgid "captcha"
msgstr "Captcha"
#: fastapi_admin/templates/providers/login/login.html:49
#, fuzzy
msgid "login_username_placeholder"
msgstr "Ingrese el nombre de usuario"
#: fastapi_admin/templates/providers/login/login.html:45
msgid "captcha_placeholder"
msgstr "Ingrese el captcha"
#: fastapi_admin/templates/providers/login/login.html:59
#, fuzzy
msgid "login_password_placeholder"
msgstr "Ingrese la contraseña antigua"
#: fastapi_admin/templates/providers/login/login.html:61
#: fastapi_admin/templates/providers/login/login.html:75
msgid "remember_me"
msgstr "Recordarme"
#: fastapi_admin/templates/providers/login/login.html:65
#: fastapi_admin/templates/providers/login/login.html:80
msgid "sign_in"
msgstr "Iniciar sesión"
@ -240,10 +198,45 @@ msgstr "Repetir nueva contraseña"
msgid "re_new_password_placeholder"
msgstr "Ingrese la nueva contraseña nuevamente"
#: fastapi_admin/templates/providers/search/search.html:11
msgid "Search in site..."
msgstr "Buscar en el sitio..."
#~ msgid "You can only try after %(seconds)s seconds"
#~ msgstr "Solo puedes intentarlo después de %(seconds)s segundos"
#~ msgid "Login failed %(times)s times, you can try %(rest_times)s more times"
#~ msgstr ""
#~ "Fallo en el inicio de sesión "
#~ "%(times)s veces, puedes intentarlo "
#~ "%(rest_times)s veces más"
#~ msgid "Import"
#~ msgstr "Importar"
#~ msgid "Export"
#~ msgstr "Exportar"
#~ msgid "Success create %(count)s %(label)s"
#~ msgstr "Éxito al crear %(count)s %(label)s"
#~ msgid "captcha_error"
#~ msgstr "Error en el captcha"
#~ msgid "Google recaptcha verify failed"
#~ msgstr "La verificación de Google reCAPTCHA falló"
#~ msgid "Format"
#~ msgstr "Formato"
#~ msgid "File to import"
#~ msgstr "Archivo a importar"
#~ msgid "captcha"
#~ msgstr "Captcha"
#~ msgid "captcha_placeholder"
#~ msgstr "Ingrese el captcha"
#~ msgid "Search in site..."
#~ msgstr "Buscar en el sitio..."
#~ msgid "No results found for search text"
#~ msgstr "No se encontraron resultados para el texto de búsqueda"
#: fastapi_admin/templates/providers/search/search_result.html:9
msgid "No results found for search text"
msgstr "No se encontraron resultados para el texto de búsqueda"

View File

@ -7,16 +7,16 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-08-06 23:07+0800\n"
"POT-Creation-Date: 2024-08-28 10:24+0100\n"
"PO-Revision-Date: 2021-04-16 22:46+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fa_IR\n"
"Language-Team: fa_IR <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
"Generated-By: Babel 2.14.0\n"
#: fastapi_admin/resources.py:91
msgid "create"
@ -115,27 +115,32 @@ msgstr "جستجو"
msgid "bulk_actions"
msgstr "اقدامات دسته‌ای"
#: fastapi_admin/templates/list.html:125
#: fastapi_admin/templates/list.html:139
msgid "actions"
msgstr "اقدامات"
#: fastapi_admin/templates/list.html:156
#: fastapi_admin/templates/list.html:170
#, python-format
msgid "Showing %(from)s to %(to)s of %(total)s entries"
msgstr "نمایش %(from)s الی %(to)s از %(total)s مورد"
#: fastapi_admin/templates/list.html:167
#: fastapi_admin/templates/list.html:181
msgid "prev_page"
msgstr "قبلی"
#: fastapi_admin/templates/list.html:188
#: fastapi_admin/templates/list.html:202
msgid "next_page"
msgstr "بعدی"
#: fastapi_admin/templates/list.html:214
msgid "delete_confirmation"
msgstr "هل أنت متأكد أنك تريد حذف هذا العنصر؟"
#: fastapi_admin/templates/update.html:23
msgid "save_and_return"
msgstr "ذخیره و بازگشت"
#: fastapi_admin/templates/errors/401.html:21
#: fastapi_admin/templates/errors/403.html:21
#: fastapi_admin/templates/errors/404.html:21
#: fastapi_admin/templates/errors/500.html:21
@ -190,3 +195,4 @@ msgstr "رمز عبور جدید را تایید کنید"
#: fastapi_admin/templates/providers/login/password.html:29
msgid "re_new_password_placeholder"
msgstr "رمز عبور جدید را دوباره وارد کنید"

View File

@ -7,16 +7,16 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-08-06 23:07+0800\n"
"POT-Creation-Date: 2024-08-28 10:24+0100\n"
"PO-Revision-Date: 2021-04-16 22:46+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr_FR\n"
"Language-Team: fr_FR <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
"Generated-By: Babel 2.14.0\n"
#: fastapi_admin/resources.py:91
msgid "create"
@ -115,27 +115,32 @@ msgstr "Search"
msgid "bulk_actions"
msgstr "Actions groupées"
#: fastapi_admin/templates/list.html:125
#: fastapi_admin/templates/list.html:139
msgid "actions"
msgstr "Actions"
#: fastapi_admin/templates/list.html:156
#: fastapi_admin/templates/list.html:170
#, python-format
msgid "Showing %(from)s to %(to)s of %(total)s entries"
msgstr "Voir %(from)s de %(to)s à %(total)s entrées"
#: fastapi_admin/templates/list.html:167
#: fastapi_admin/templates/list.html:181
msgid "prev_page"
msgstr "Prec"
#: fastapi_admin/templates/list.html:188
#: fastapi_admin/templates/list.html:202
msgid "next_page"
msgstr "Suiv"
#: fastapi_admin/templates/list.html:214
msgid "delete_confirmation"
msgstr "Etes-vous sûr de vouloir supprimer cet élément ?"
#: fastapi_admin/templates/update.html:23
msgid "save_and_return"
msgstr "Enregistrer et retourner"
#: fastapi_admin/templates/errors/401.html:21
#: fastapi_admin/templates/errors/403.html:21
#: fastapi_admin/templates/errors/404.html:21
#: fastapi_admin/templates/errors/500.html:21

View File

@ -7,16 +7,16 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-08-06 23:07+0800\n"
"POT-Creation-Date: 2024-08-28 10:24+0100\n"
"PO-Revision-Date: 2021-04-16 22:46+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: zh_Hans_CN\n"
"Language-Team: zh_Hans_CN <LL@li.org>\n"
"Plural-Forms: nplurals=1; plural=0\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
"Generated-By: Babel 2.14.0\n"
#: fastapi_admin/resources.py:91
msgid "create"
@ -115,27 +115,32 @@ msgstr "查询"
msgid "bulk_actions"
msgstr "批量操作"
#: fastapi_admin/templates/list.html:125
#: fastapi_admin/templates/list.html:139
msgid "actions"
msgstr "动作"
#: fastapi_admin/templates/list.html:156
#: fastapi_admin/templates/list.html:170
#, python-format
msgid "Showing %(from)s to %(to)s of %(total)s entries"
msgstr "显示 %(from)s 到 %(to)s 共 %(total)s 项"
#: fastapi_admin/templates/list.html:167
#: fastapi_admin/templates/list.html:181
msgid "prev_page"
msgstr "上一页"
#: fastapi_admin/templates/list.html:188
#: fastapi_admin/templates/list.html:202
msgid "next_page"
msgstr "下一页"
#: fastapi_admin/templates/list.html:214
msgid "delete_confirmation"
msgstr "您确定要删除该项目吗?"
#: fastapi_admin/templates/update.html:23
msgid "save_and_return"
msgstr "保存并返回"
#: fastapi_admin/templates/errors/401.html:21
#: fastapi_admin/templates/errors/403.html:21
#: fastapi_admin/templates/errors/404.html:21
#: fastapi_admin/templates/errors/500.html:21

View File

@ -116,7 +116,7 @@
{% if model_resource.bulk_actions %}
<td>
<input
data-id="{{ value[0]|int }}"
data-id="{{ value[0] }}"
class="form-check-input m-0 align-middle checkbox-select-item"
type="checkbox"
/>
@ -209,7 +209,18 @@
</div>
</div>
<script>
function confirmAction(method) {
if (method === "DELETE") {
if (!confirm("{{ _('delete_confirmation') }}")) {
return false;
}
}
return true;
}
function onAction(url, method) {
if(!confirmAction(method)) {
return
}
$.ajax({
url: url,
method: method,
@ -220,6 +231,9 @@
}
function onBulkAction(url, method) {
if(!confirmAction(method)) {
return
}
let ids = $('.checkbox-select-item:checked').map(function () {
return $(this).attr('data-id')
}).get();