• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python helpers.render_template函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中metabomatch.flaskbb.utils.helpers.render_template函数的典型用法代码示例。如果您正苦于以下问题:Python render_template函数的具体用法?Python render_template怎么用?Python render_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了render_template函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: search

def search():
    form = SearchPageForm()

    if form.validate_on_submit():
        result = form.get_results()
        return render_template('forum/search_result.html', form=form,
                               result=result)

    return render_template('forum/search_form.html', form=form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:9,代码来源:views.py


示例2: memberlist

def memberlist():
    page = request.args.get('page', 1, type=int)

    search_form = UserSearchForm()

    if search_form.validate():
        users = search_form.get_results().\
            paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
        return render_template("forum/memberlist.html", users=users,
                               search_form=search_form)
    else:
        users = User.query.\
            paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
        return render_template("forum/memberlist.html", users=users,
                               search_form=search_form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:15,代码来源:views.py


示例3: who_is_online

def who_is_online():
    if current_app.config['REDIS_ENABLED']:
        online_users = get_online_users()
    else:
        online_users = User.query.filter(User.lastseen >= time_diff()).all()
    return render_template("forum/online_users.html",
                           online_users=online_users)
开发者ID:jerkos,项目名称:metabo-match,代码行数:7,代码来源:views.py


示例4: edit_post

def edit_post(post_id):
    post = Post.query.filter_by(id=post_id).first_or_404()

    if post.topic.forum.locked:
        flash("This forum is locked; you cannot submit new topics or posts.",
              "danger")
        return redirect(post.topic.forum.url)

    if post.topic.locked:
        flash("The topic is locked.", "danger")
        return redirect(post.topic.forum.url)

    if not can_edit_post(user=current_user, forum=post.topic.forum,
                         post_user_id=post.user_id):
        flash("You do not have the permissions to edit this post", "danger")
        return redirect(post.topic.url)

    form = ReplyForm()
    if form.validate_on_submit():
        # if "preview" in request.form:
        #     return render_template(
        #         "forum/new_post.html", topic=post.topic,
        #         form=form, preview=form.content.data
        #     )
        # else:
        form.populate_obj(post)
        post.date_modified = datetime.datetime.utcnow()
        post.modified_by = current_user.username
        post.save()
        return redirect(post.topic.url)
    else:
        form.content.data = post.content

    return render_template("forum/new_post.html", topic=post.topic, form=form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:34,代码来源:views.py


示例5: index

def index():
    categories = Category.get_all(user=current_user)

    # Fetch a few stats about the forum
    user_count = User.query.count()
    topic_count = Topic.query.count()
    post_count = Post.query.count()
    newest_user = User.query.order_by(User.id.desc()).first()

    # Check if we use redis or not
    if not current_app.config["REDIS_ENABLED"]:
        online_users = User.query.filter(User.lastseen >= time_diff()).count()

        # Because we do not have server side sessions, we cannot check if there
        # are online guests
        online_guests = None
    else:
        online_users = len(get_online_users())
        online_guests = len(get_online_users(guest=True))

    return render_template("forum/index.html",
                           categories=categories,
                           user_count=user_count,
                           topic_count=topic_count,
                           post_count=post_count,
                           newest_user=newest_user,
                           online_users=online_users,
                           online_guests=online_guests)
开发者ID:jerkos,项目名称:metabo-match,代码行数:28,代码来源:views.py


示例6: new_post

def new_post(topic_id, slug=None):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()

    if topic.forum.locked:
        flash("This forum is locked; you cannot submit new topics or posts.",
              "danger")
        return redirect(topic.forum.url)

    if topic.locked:
        flash("The topic is locked.", "danger")
        return redirect(topic.forum.url)

    if not can_post_reply(user=current_user, forum=topic.forum):
        flash("You do not have the permissions to delete the topic", "danger")
        return redirect(topic.forum.url)

    form = ReplyForm()
    if form.validate_on_submit():
        # if "preview" in request.form:
        #     return render_template(
        #         "forum/new_post.html", topic=topic,
        #         form=form, preview=form.content.data
        #     )
        # else:
        post = form.save(current_user, topic)
        return view_post(post.id)

    return render_template("forum/new_post.html", topic=topic, form=form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:28,代码来源:views.py


示例7: new_topic

def new_topic(forum_id, slug=None):
    forum_instance = Forum.query.filter_by(id=forum_id).first_or_404()

    if forum_instance.locked:
        flash("This forum is locked; you cannot submit new topics or posts.",
              "danger")
        return redirect(forum_instance.url)

    if not can_post_topic(user=current_user, forum=forum_instance):
        flash("You do not have the permissions to create a new topic.",
              "danger")
        return redirect(forum_instance.url)

    form = NewTopicForm()
    if request.method == "POST":
        # if "preview" in request.form and form.validate():
        #     return render_template(
        #         "forum/new_topic.html", forum=forum_instance,
        #         form=form, preview=form.content.data
        #     )
        if "submit" in request.form and form.validate():
            topic = form.save(current_user, forum_instance)

            # redirect to the new topic
            return redirect(url_for('forum.view_topic', topic_id=topic.id))

    return render_template("forum/new_topic.html", forum=forum, form=form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:27,代码来源:views.py


示例8: edit_user

def edit_user(user_id):
    user = User.query.filter_by(id=user_id).first_or_404()

    if not can_edit_user(current_user):
        flash("You are not allowed to edit this user.", "danger")
        return redirect(url_for("management.users"))

    secondary_group_query = Group.query.filter(
        db.not_(Group.id == user.primary_group_id),
        db.not_(Group.banned == True),
        db.not_(Group.guest == True))

    form = EditUserForm(user)
    form.secondary_groups.query = secondary_group_query
    if form.validate_on_submit():
        form.populate_obj(user)
        user.primary_group_id = form.primary_group.data.id

       # Don't override the password
        if form.password.data:
            user.password = form.password.data

        user.save(groups=form.secondary_groups.data)

        flash("User successfully edited", "success")
        return redirect(url_for("management.edit_user", user_id=user.id))

    return render_template("management/user_form.html", form=form,
                           title="Edit User")
开发者ID:jerkos,项目名称:metabo-match,代码行数:29,代码来源:views.py


示例9: register

def register():
    """register a new software"""
    form = SoftwareForm()
    if form.validate_on_submit():
        form.save(request.form.getlist('selected_tags'))

        #update achivements
        c = db.session.query(Software.name).filter(Software.owner_id == current_user.id).count()
        goal = SoftwareAchievement.unlocked_level(c)
        if goal:
            flash('Achievement unlocked\n {} \n {}'.format(goal['name'], goal['description']), 'success')

        #update global score
        current_user.global_score += SCORE_SOFT
        current_user.save()

        #upload to s3
        if form.image.data:
            s3_upload(form.image, form.name.data.lower())
        else:
            s3_upload_from_server('static/img/placeholder.jpg', form.name.data.lower())

        return redirect(url_for('softwares.index'))

    last_soft_name = db.session.query(Software.name).order_by(desc(Software.insertion_date)).first()[0]
    tot_soft_count = db.session.query(Software.name).count()
    return render_template('softwares/register_software.html', form=form,
                           last_soft_name=last_soft_name, tot_soft_count=tot_soft_count)
开发者ID:jerkos,项目名称:metabo-match,代码行数:28,代码来源:views.py


示例10: users

def users():
    page = request.args.get("page", 1, type=int)
    search_form = UserSearchForm()

    if search_form.validate():
        users = search_form.get_results().\
            paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
        return render_template("management/users.html", users=users,
                               search_form=search_form)

    users = User.query. \
        order_by(User.id.asc()).\
        paginate(page, flaskbb_config['USERS_PER_PAGE'], False)

    return render_template("management/users.html", users=users,
                           search_form=search_form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:16,代码来源:views.py


示例11: sent

def sent():
    messages = PrivateMessage.query.filter(
        PrivateMessage.user_id == current_user.id,
        PrivateMessage.draft == False,
        PrivateMessage.trash == False,
        db.not_(PrivateMessage.to_user_id == current_user.id)).all()
    return render_template("message/sent.html", messages=messages)
开发者ID:jerkos,项目名称:metabo-match,代码行数:7,代码来源:views.py


示例12: info

def info(name):
    """
    get some infos on requested software name being the primary key
    count number of times no logged user call this endpoint. If > 3
    user us automatically redirected to authentification login default

    :param name: software name PK
    :return:
    """
    soft = Software.query.filter(Software.name == name).first_or_404()

    # view restriction
    # if not current_user.is_authenticated():
    #     v = session.get('nb_views', 0)
    #     session['nb_views'] = v + 1
    #
    #     if session['nb_views'] > 3:
    #         flash("Please register or log in to see more about softwares", "info")
    #         #redirect to softwares by default
    #         return redirect(url_for('auth.login', next=url_for('softwares.info', name=name)))

    show_comment_form = True if 'show_comment_form' in request.args else False

    return render_template('softwares/software.html',
                           software=soft,
                           show_comment_form=show_comment_form,
                           form=Form())
开发者ID:jerkos,项目名称:metabo-match,代码行数:27,代码来源:views.py


示例13: index

def index():
    page = request.args.get("page", 1, type=int)
    software, tags = request.args.get('software'), request.args.get('tags')
    softwares = [s.name for s in Software.query.distinct(Software.name)]

    not_tags = tags is None or not tags
    tags = tags is not None and tags

    if software is not None and not_tags:
        if software == '---':
            filtered_scripts = Script.query.filter(Script.software_id == None).order_by(desc(Script.creation_date))\
                .paginate(page, SCRIPTS_PER_PAGE, True)
        else:
            filtered_scripts = Script.query.join(Software).filter(Software.name == software)\
                .paginate(page, SCRIPTS_PER_PAGE, True)
    elif (software is None or software == '---') and tags:
        tags_list = tags.split(',')
        filtered_scripts = Script.query.join(Script.script_tags).filter(ScriptTags.name.in_(tags_list))\
            .paginate(page, SCRIPTS_PER_PAGE, True)
    elif software is not None and tags:
        tags_list = tags.split(',')
        filtered_scripts = Script.query.join(Software).join(Script.script_tags)\
                                                      .filter(and_(Software.name == software, ScriptTags.name.in_(tags_list)))\
            .paginate(page, SCRIPTS_PER_PAGE, True)
    else:
        filtered_scripts = Script.query.order_by(desc(Script.creation_date)).paginate(page, SCRIPTS_PER_PAGE, True)
    return render_template('scripts/scripts.html',
                           scripts=filtered_scripts,
                           softwares=softwares,
                           search_form=Form())
开发者ID:jerkos,项目名称:metabo-match,代码行数:30,代码来源:views.py


示例14: reset_password

def reset_password(token):
    """
    Handles the reset password process.
    """

    if not current_user.is_anonymous():
        return redirect(url_for("forum.index"))

    form = ResetPasswordForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        expired, invalid, data = user.verify_reset_token(form.token.data)

        if invalid:
            flash("Your password token is invalid.", "danger")
            return redirect(url_for("auth.forgot_password"))

        if expired:
            flash("Your password is expired.", "danger")
            return redirect(url_for("auth.forgot_password"))

        if user and data:
            user.password = form.password.data
            user.save()
            flash("Your password has been updated.", "success")
            return redirect(url_for("auth.login"))

    form.token.data = token
    return render_template("auth/reset_password.html", form=form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:29,代码来源:views.py


示例15: reports

def reports():
    page = request.args.get("page", 1, type=int)
    reports = Report.query.\
        order_by(Report.id.asc()).\
        paginate(page, flaskbb_config['USERS_PER_PAGE'], False)

    return render_template("management/reports.html", reports=reports)
开发者ID:jerkos,项目名称:metabo-match,代码行数:7,代码来源:views.py


示例16: unread_reports

def unread_reports():
    page = request.args.get("page", 1, type=int)
    reports = Report.query.\
        filter(Report.zapped == None).\
        order_by(Report.id.desc()).\
        paginate(page, flaskbb_config['USERS_PER_PAGE'], False)

    return render_template("management/unread_reports.html", reports=reports)
开发者ID:jerkos,项目名称:metabo-match,代码行数:8,代码来源:views.py


示例17: change_password

def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        current_user.password = form.new_password.data
        current_user.save()

        flash("Your password have been updated!", "success")
    return render_template("user/change_password.html", form=form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:8,代码来源:views.py


示例18: groups

def groups():
    page = request.args.get("page", 1, type=int)

    groups = Group.query.\
        order_by(Group.id.asc()).\
        paginate(page, flaskbb_config['USERS_PER_PAGE'], False)

    return render_template("management/groups.html", groups=groups)
开发者ID:jerkos,项目名称:metabo-match,代码行数:8,代码来源:views.py


示例19: change_email

def change_email():
    form = ChangeEmailForm(current_user)
    if form.validate_on_submit():
        current_user.email = form.new_email.data
        current_user.save()

        flash("Your email have been updated!", "success")
    return render_template("user/change_email.html", form=form)
开发者ID:jerkos,项目名称:metabo-match,代码行数:8,代码来源:views.py


示例20: add_user

def add_user():
    form = AddUserForm()
    if form.validate_on_submit():
        form.save()
        flash("User successfully added.", "success")
        return redirect(url_for("management.users"))

    return render_template("management/user_form.html", form=form,
                           title="Add User")
开发者ID:jerkos,项目名称:metabo-match,代码行数:9,代码来源:views.py



注:本文中的metabomatch.flaskbb.utils.helpers.render_template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python user.User类代码示例发布时间:2022-05-27
下一篇:
Python views.MetadataMixin类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap