littlefix
parent
2cf2b3d0c0
commit
23e8a2e492
|
@ -13,17 +13,10 @@ class MyAdminView(sqla.ModelView):
|
|||
)
|
||||
|
||||
def _handle_view(self, name, **kwargs):
|
||||
"""
|
||||
Override builtin _handle_view in
|
||||
order to redirect users when a
|
||||
view is not accessible.
|
||||
"""
|
||||
if not self.is_accessible():
|
||||
if current_user.is_authenticated:
|
||||
# permission denied
|
||||
abort(403)
|
||||
else:
|
||||
# login
|
||||
return redirect(url_for("security.login", next=request.url))
|
||||
|
||||
|
||||
|
@ -59,7 +52,10 @@ class RoleView(MyAdminView):
|
|||
"name",
|
||||
"description",
|
||||
)
|
||||
column_labels = dict(name="Название", description="Описание")
|
||||
column_labels = dict(
|
||||
name="Название",
|
||||
description="Описание",
|
||||
)
|
||||
|
||||
|
||||
class TagView(MyAdminView):
|
||||
|
@ -67,12 +63,6 @@ class TagView(MyAdminView):
|
|||
|
||||
|
||||
class PostView(MyAdminView):
|
||||
# form_excluded_columns = (
|
||||
# "author",
|
||||
# "create_datetime",
|
||||
# "update_datetime",
|
||||
# "text",
|
||||
# )
|
||||
column_list = (
|
||||
"title",
|
||||
"published",
|
||||
|
@ -89,7 +79,6 @@ class PostView(MyAdminView):
|
|||
text="Текст",
|
||||
)
|
||||
|
||||
# override form type with CKEditorField
|
||||
form_overrides = dict(text=CKEditorField)
|
||||
create_template = "admin/edit.html"
|
||||
edit_template = "admin/edit.html"
|
||||
|
|
|
@ -2,46 +2,71 @@ import datetime
|
|||
|
||||
from flask_security.models import fsqla
|
||||
from sqlalchemy import Boolean, Column, DateTime, Integer, String, Text
|
||||
from sqlalchemy.util import unique_list
|
||||
|
||||
from . import db
|
||||
|
||||
|
||||
class Role(db.Model, fsqla.FsRoleMixin):
|
||||
def __str__(self) -> str:
|
||||
name = Column(
|
||||
String(80),
|
||||
unique=True,
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class User(db.Model, fsqla.FsUserMixin):
|
||||
first_name = Column(String(255))
|
||||
last_name = Column(String(255))
|
||||
posts = db.relationship("Post", backref="user", lazy="dynamic")
|
||||
posts = db.relationship(
|
||||
"Post",
|
||||
backref="user",
|
||||
lazy="dynamic",
|
||||
)
|
||||
|
||||
def __str__(self) -> str:
|
||||
def __str__(self):
|
||||
return self.email
|
||||
|
||||
|
||||
tag_post = db.Table(
|
||||
"tag_post",
|
||||
db.Column("tag_id", db.Integer, db.ForeignKey("tag.id")),
|
||||
db.Column("post_id", db.Integer, db.ForeignKey("post.id")),
|
||||
db.Column(
|
||||
"tag_id",
|
||||
db.Integer,
|
||||
db.ForeignKey("tag.id"),
|
||||
),
|
||||
db.Column(
|
||||
"post_id",
|
||||
db.Integer,
|
||||
db.ForeignKey("post.id"),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class Tag(db.Model):
|
||||
__tablename__ = "tag"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
id = Column(
|
||||
Integer,
|
||||
primary_key=True,
|
||||
autoincrement=True,
|
||||
)
|
||||
tag = Column(String(20))
|
||||
|
||||
def __str__(self) -> str:
|
||||
def __str__(self):
|
||||
return self.tag
|
||||
|
||||
|
||||
class Post(db.Model):
|
||||
__tablename__ = "post"
|
||||
id = Column(
|
||||
Integer, primary_key=True, nullable=False, unique=True, autoincrement=True
|
||||
Integer,
|
||||
primary_key=True,
|
||||
nullable=False,
|
||||
unique=True,
|
||||
autoincrement=True,
|
||||
)
|
||||
author = Column(Integer, db.ForeignKey("user.id"))
|
||||
slug = Column(String(30), nullable=False)
|
||||
|
@ -50,7 +75,9 @@ class Post(db.Model):
|
|||
tags = db.relationship("Tag", secondary=tag_post)
|
||||
|
||||
create_datetime = Column(
|
||||
DateTime(), nullable=True, default=datetime.datetime.utcnow()
|
||||
DateTime(),
|
||||
nullable=True,
|
||||
default=datetime.datetime.utcnow(),
|
||||
)
|
||||
update_datetime = Column(
|
||||
DateTime(),
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
# Russian translations for PROJECT.
|
||||
# Copyright (C) 2023 ORGANIZATION
|
||||
# This file is distributed under the same license as the PROJECT project.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2023-07-03 23:52+0300\n"
|
||||
"PO-Revision-Date: 2023-07-02 22:55+0300\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language: ru\n"
|
||||
"Language-Team: ru <LL@li.org>\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
|
||||
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.12.1\n"
|
||||
|
||||
#: pi3code/admin/views.py:64
|
||||
msgid "Tags"
|
||||
msgstr "Тэги"
|
||||
|
||||
#: pi3code/admin/views.py:65
|
||||
msgid "Title"
|
||||
msgstr "Заголовок"
|
||||
|
||||
#: pi3code/admin/views.py:66
|
||||
msgid "Author"
|
||||
msgstr "Автор"
|
||||
|
||||
#: pi3code/admin/views.py:67
|
||||
msgid "Published"
|
||||
msgstr "Опубликован"
|
||||
|
||||
#: pi3code/admin/views.py:68
|
||||
msgid "Publication day"
|
||||
msgstr "Дата публикации"
|
||||
|
||||
#: pi3code/templates/admin/index.html:29
|
||||
msgid "Back"
|
||||
msgstr "Назад"
|
||||
|
||||
#~ msgid "Name"
|
||||
#~ msgstr "тема"
|
||||
|
||||
#~ msgid "\"\"Translation and localization commands.\"\""
|
||||
#~ msgstr "\"\"Команды для перевода и локализации\"\""
|
||||
|
Loading…
Reference in New Issue