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

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", "active",
"roles", "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): class RoleView(MyAdminView):
@ -41,25 +59,35 @@ class RoleView(MyAdminView):
"name", "name",
"description", "description",
) )
column_labels = dict(name="Название", description="Описание")
class TagView(MyAdminView): class TagView(MyAdminView):
pass column_labels = dict(tag="Тэг")
class PostView(MyAdminView): class PostView(MyAdminView):
# # form_excluded_columns = ("author", "create_datetime", "update_datetime") # form_excluded_columns = (
# column_list = ( # "author",
# "title", # "create_datetime",
# "published", # "update_datetime",
# ) # "text",
# column_labels = dict( # )
# tags="Tags", column_list = (
# title="Title", "title",
# author="Author", "published",
# published="Published", "tags",
# published_datetime="Pubdate", )
# ) column_labels = dict(
tags="Тэги",
slug="Слаг",
title="Заголовок",
author="Автор",
published="Опубликовано",
create_datetime="Дата создания",
update_datetime="Дата обновления",
text="Текст",
)
# override form type with CKEditorField # override form type with CKEditorField
form_overrides = dict(text=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 from pyproger.admin.views import PostView, RoleView, TagView, UserView
admin.add_view(RoleView(Role, db.session, category="Пользователи")) admin.add_view(
admin.add_view(UserView(User, db.session, category="Пользователи")) RoleView(
admin.add_view(TagView(Tag, db.session, category="Посты")) Role,
admin.add_view(PostView(Post, db.session, category="Посты")) 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 from pyproger.cli.commands import bp_cli