добавил tag description на страницы
parent
52d1b84658
commit
50e74ccf38
|
@ -0,0 +1,33 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 055327bef08e
|
||||
Revises: 849ff22feb97
|
||||
Create Date: 2023-10-23 09:29:00.193470
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import flask_security
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '055327bef08e'
|
||||
down_revision = '849ff22feb97'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('page', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('header_description', sa.Text(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('page', schema=None) as batch_op:
|
||||
batch_op.drop_column('header_description')
|
||||
|
||||
# ### end Alembic commands ###
|
|
@ -0,0 +1,53 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 849ff22feb97
|
||||
Revises: 68537cc1688c
|
||||
Create Date: 2023-10-23 08:34:08.251453
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import flask_security
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '849ff22feb97'
|
||||
down_revision = '68537cc1688c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('footer_icons', schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint(None, ['id'])
|
||||
|
||||
with op.batch_alter_table('page', schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint(None, ['id'])
|
||||
|
||||
with op.batch_alter_table('post', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('header_description', sa.Text(), nullable=True))
|
||||
batch_op.create_unique_constraint(None, ['id'])
|
||||
|
||||
with op.batch_alter_table('site_headers', schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint(None, ['id'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('site_headers', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(None, type_='unique')
|
||||
|
||||
with op.batch_alter_table('post', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(None, type_='unique')
|
||||
batch_op.drop_column('header_description')
|
||||
|
||||
with op.batch_alter_table('page', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(None, type_='unique')
|
||||
|
||||
with op.batch_alter_table('footer_icons', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(None, type_='unique')
|
||||
|
||||
# ### end Alembic commands ###
|
|
@ -72,6 +72,7 @@ class PostView(MyAdminView):
|
|||
tags="Тэги",
|
||||
slug="Слаг",
|
||||
title="Заголовок",
|
||||
header_description="description заголовок в head страницы",
|
||||
description="Краткое описание статьи",
|
||||
author="Автор",
|
||||
published="Опубликовано",
|
||||
|
@ -92,6 +93,7 @@ class PostView(MyAdminView):
|
|||
class PageView(MyAdminView):
|
||||
column_labels = dict(
|
||||
name="Название страницы",
|
||||
header_description="description заголовок в head страницы",
|
||||
slug="URL страницы",
|
||||
text="Содержимое страницы",
|
||||
)
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
import locale
|
||||
import re
|
||||
|
||||
from flask import abort, current_app, redirect, render_template, request, url_for
|
||||
from flask import (abort, current_app, redirect, render_template, request,
|
||||
url_for)
|
||||
|
||||
from ..dbase.database import (
|
||||
get_all_posts_by_tag,
|
||||
get_page,
|
||||
get_paginated_posts,
|
||||
get_post,
|
||||
get_tags,
|
||||
)
|
||||
from ..dbase.database import (get_all_posts_by_tag, get_page,
|
||||
get_paginated_posts, get_post, get_tags)
|
||||
from .blog import bp
|
||||
|
||||
locale.setlocale(locale.LC_ALL, ("ru", "utf-8"))
|
||||
|
@ -29,6 +25,7 @@ def index(page=1):
|
|||
return render_template(
|
||||
"blog/index.html",
|
||||
title=f'{current_app.config.get("BRAND")} - разговоры про питон',
|
||||
header_description="Про изучение python, веб разработку и прочие вещи",
|
||||
headers=current_app.config.get("SITE_HEADERS"),
|
||||
menu_title=current_app.config.get("BRAND"),
|
||||
menu_items=current_app.config.get("MENU_ITEMS"),
|
||||
|
@ -77,6 +74,7 @@ def get_all_tags():
|
|||
return render_template(
|
||||
"blog/tags.html",
|
||||
title=f'{current_app.config.get("BRAND")} - поиск по тэгу',
|
||||
header_description="Выбор статей по тематике",
|
||||
headers=current_app.config.get("SITE_HEADERS"),
|
||||
menu_title=current_app.config.get("BRAND"),
|
||||
tags=tags,
|
||||
|
@ -91,7 +89,6 @@ def get_all_tags():
|
|||
def get_posts_by_tag(page=1, tag=None):
|
||||
per_page = current_app.config.get("POSTS_ON_PAGE")
|
||||
posts, total = get_all_posts_by_tag(tag, page, per_page)
|
||||
|
||||
if posts is None:
|
||||
abort(404)
|
||||
|
||||
|
@ -104,6 +101,7 @@ def get_posts_by_tag(page=1, tag=None):
|
|||
return render_template(
|
||||
"blog/tagget_posts.html",
|
||||
title=f'{current_app.config.get("BRAND")} - посты по {tag}',
|
||||
header_description=f"Статьи по теме {tag}",
|
||||
headers=current_app.config.get("SITE_HEADERS"),
|
||||
menu_title=current_app.config.get("BRAND"),
|
||||
menu_items=current_app.config.get("MENU_ITEMS"),
|
||||
|
@ -125,6 +123,7 @@ def page(slug=None):
|
|||
return render_template(
|
||||
"blog/page.html",
|
||||
title=f'{current_app.config.get("BRAND")} - {page.name}',
|
||||
header_description=page.header_description,
|
||||
headers=current_app.config.get("SITE_HEADERS"),
|
||||
menu_title=current_app.config.get("BRAND"),
|
||||
menu_items=current_app.config.get("MENU_ITEMS"),
|
||||
|
|
|
@ -72,6 +72,7 @@ class Post(db.Model):
|
|||
author = Column(Integer, db.ForeignKey("user.id"))
|
||||
slug = Column(String(100), nullable=False)
|
||||
title = Column(Text, nullable=False)
|
||||
header_description = Column(Text)
|
||||
description = Column(Text, nullable=False)
|
||||
published = Column(Boolean, default=False)
|
||||
tags = db.relationship("Tag", secondary=tag_post)
|
||||
|
@ -99,6 +100,7 @@ class Page(db.Model):
|
|||
unique=True,
|
||||
autoincrement=True,
|
||||
)
|
||||
header_description = Column(Text)
|
||||
name = Column(String(20))
|
||||
slug = Column(String(50), nullable=False)
|
||||
text = Column(Text)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
<title>{% block title %}{% endblock title %}</title>
|
||||
<meta name="description" content="{% block header_description %}{% endblock header_description %}" />
|
||||
{% for h in headers %}
|
||||
{{h.content | safe}}
|
||||
{% endfor %}
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
{{title}}
|
||||
{% endblock %}
|
||||
|
||||
{% block header_description %}
|
||||
{{ header_description }}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu_title %}
|
||||
{{ menu_title }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
{{ menu_title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block header_description %}
|
||||
{{ header_description }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<!-- Main Content-->
|
||||
<div class="conteiner ">
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block header_description%}
|
||||
{{ post.Post.header_description }}
|
||||
{% endblock%}
|
||||
|
||||
{% block menu_title %}
|
||||
{{ menu_title }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
{{title}}
|
||||
{% endblock %}
|
||||
|
||||
{% block header_description %}
|
||||
{{ header_description }}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu_title %}
|
||||
{{ menu_title }}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue