Exemplo n.º 1
0
    def common(page_slug):
        get_user_id = current_user.get_id()
        user_by_id = Users.query.filter_by(id=get_user_id).first()

        g.username = user_by_id.username
        g.role = user_by_id.role
        g.avatar = user_by_id.avatar

        page_content = Content.query.with_entities(
            Content.description, Content.type, Content.url,
            Content.lesson_name,
            Content.url_description).filter(Content.slug != "").filter(
                (or_(Content.section_name.ilike('%первой%'),
                     Content.section_name.ilike('%2 недели%'),
                     Content.section_name.ilike('%окружение%')))).filter(
                         Content.slug == page_slug).distinct()

        page = Content.query.with_entities(
            Content.slug).filter(Content.slug == page_slug).first()
        if not page:
            return 'Not found', 404

        return render_template(f'/common/{page.slug}.html',
                               page_content=page_content,
                               username=g.username,
                               role=g.role,
                               common_menu=Content.common_menu(),
                               web_menu=Content.web_menu(),
                               ds_menu=Content.ds_menu(),
                               bot_menu=Content.bot_menu(),
                               deploy_menu=Content.deploy_menu(),
                               add_menu=Content.add_menu())
Exemplo n.º 2
0
    def start():
        get_user_id = current_user.get_id()
        user_by_id = Users.query.filter_by(id=get_user_id).first()

        g.username = user_by_id.username
        g.role = user_by_id.role
        g.avatar = user_by_id.avatar
        return render_template('start.html',
                               username=g.username,
                               role=g.role,
                               common_menu=Content.common_menu(),
                               web_menu=Content.web_menu(),
                               ds_menu=Content.ds_menu(),
                               bot_menu=Content.bot_menu(),
                               deploy_menu=Content.deploy_menu(),
                               add_menu=Content.add_menu())
Exemplo n.º 3
0
    def add(page_slug):
        get_user_id = current_user.get_id()
        user_by_id = Users.query.filter_by(id=get_user_id).first()

        g.username = user_by_id.username
        g.role = user_by_id.role
        g.avatar = user_by_id.avatar

        page = Content.query.with_entities(
            Content.slug).filter(Content.slug == page_slug).first()
        if not page:
            return 'Not found', 404

        return render_template(f'/add/{page.slug}.html',
                               username=g.username,
                               role=g.role,
                               page_content=Content.page_content(page_slug),
                               common_menu=Content.common_menu(),
                               web_menu=Content.web_menu(),
                               ds_menu=Content.ds_menu(),
                               bot_menu=Content.bot_menu(),
                               deploy_menu=Content.deploy_menu(),
                               add_menu=Content.add_menu())
Exemplo n.º 4
0
    def index():
        get_user_id = current_user.get_id()
        user_by_id = Users.query.filter_by(id=get_user_id).first()

        g.username = user_by_id.username
        g.role = user_by_id.role
        g.avatar = user_by_id.avatar

        news_list = News.query.order_by(News.published.desc()).all()
        habr_list = Articles.query.filter_by(source="habr").all()
        tproger_list = Articles.query.filter_by(source="tproger").all()

        return render_template('index.html',
                               news_list=news_list,
                               habr_list=habr_list,
                               tproger_list=tproger_list,
                               username=g.username,
                               role=g.role,
                               common_menu=Content.common_menu(),
                               web_menu=Content.web_menu(),
                               ds_menu=Content.ds_menu(),
                               bot_menu=Content.bot_menu(),
                               deploy_menu=Content.deploy_menu(),
                               add_menu=Content.add_menu())