Перевод моделей админки

main
Сергей Ванюшкин 2023-09-21 22:44:25 +03:00
parent 33bfcfc9df
commit 2cf2b3d0c0
2 changed files with 73 additions and 17 deletions

View File

@ -34,6 +34,24 @@ class UserView(MyAdminView):
"active",
"roles",
)
column_labels = dict(
first_name="Имя",
last_name="Фамилия",
posts="Посты",
roles="Роли",
email="Эл. почта",
username="Ник",
password="Хэш пароля",
active="Активирован",
confirmed_at="Подтвержден",
last_login_at="Последний login",
current_login_at="Текущий login",
last_login_ip="Последний ip",
current_login_ip="Текущий ip",
login_count="Кол-во входов",
create_datetime="Дата создания",
update_datetime="Дата обновления",
)
class RoleView(MyAdminView):
@ -41,25 +59,35 @@ class RoleView(MyAdminView):
"name",
"description",
)
column_labels = dict(name="Название", description="Описание")
class TagView(MyAdminView):
pass
column_labels = dict(tag="Тэг")
class PostView(MyAdminView):
# # form_excluded_columns = ("author", "create_datetime", "update_datetime")
# column_list = (
# "title",
# "published",
# )
# column_labels = dict(
# tags="Tags",
# title="Title",
# author="Author",
# published="Published",
# published_datetime="Pubdate",
# )
# form_excluded_columns = (
# "author",
# "create_datetime",
# "update_datetime",
# "text",
# )
column_list = (
"title",
"published",
"tags",
)
column_labels = dict(
tags="Тэги",
slug="Слаг",
title="Заголовок",
author="Автор",
published="Опубликовано",
create_datetime="Дата создания",
update_datetime="Дата обновления",
text="Текст",
)
# override form type with CKEditorField
form_overrides = dict(text=CKEditorField)

View File

@ -39,10 +39,38 @@ def create_app(test_config=None):
from pyproger.admin.views import PostView, RoleView, TagView, UserView
admin.add_view(RoleView(Role, db.session, category="Пользователи"))
admin.add_view(UserView(User, db.session, category="Пользователи"))
admin.add_view(TagView(Tag, db.session, category="Посты"))
admin.add_view(PostView(Post, db.session, category="Посты"))
admin.add_view(
RoleView(
Role,
db.session,
category="Пользователи",
name="Роли",
)
)
admin.add_view(
UserView(
User,
db.session,
category="Пользователи",
name="Юзеры",
)
)
admin.add_view(
TagView(
Tag,
db.session,
category="Посты",
name="Тэги постов",
)
)
admin.add_view(
PostView(
Post,
db.session,
category="Посты",
name="Посты",
)
)
from pyproger.cli.commands import bp_cli