示例#1
0
def test_format_quote(topic):
    expected_bbcode = "[b][url=http://localhost:5000/user/test_normal]test_normal[/url] wrote:[/b][quote]Test Content Normal[/quote]\n"
    expected_markdown = "**[test_normal](http://localhost:5000/user/test_normal) wrote:**\n> Test Content Normal\n"

    flaskbb_config["MARKUP_TYPE"] = "bbcode"
    assert format_quote(topic.first_post) == expected_bbcode

    flaskbb_config["MARKUP_TYPE"] = "markdown"
    assert format_quote(topic.first_post) == expected_markdown
示例#2
0
文件: views.py 项目: aregsar/flaskbb
def reply_post(topic_id, post_id):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()
    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_post_reply(user=current_user, forum=topic.forum):
        flash("You do not have the permissions to post in this topic", "danger")
        return redirect(topic.forum.url)

    form = ReplyForm()
    if form.validate_on_submit():
        if request.form['button'] == 'preview':
            return render_template("forum/new_post.html", topic=topic,
                                   form=form, preview=form.content.data)
        else:
            form.save(current_user, topic)
            return redirect(post.topic.url)
    else:
        form.content.data = format_quote(post)

    return render_template("forum/new_post.html", topic=post.topic, form=form)
示例#3
0
    def get(self, topic_id, slug=None, post_id=None):
        topic = Topic.query.filter_by(id=topic_id).first_or_404()
        form = self.form()

        if post_id is not None:
            post = Post.query.filter_by(id=post_id).first_or_404()
            form.content.data = format_quote(post.username, post.content)

        return render_template('forum/new_post.html', topic=topic, form=form)
示例#4
0
文件: views.py 项目: 0xsKu/flaskbb
def raw_message(message_id):
    message = Message.query.filter_by(id=message_id).first_or_404()

    # abort if the message was not the current_user's one or the one of the
    # recieved ones
    if not (message.conversation.from_user_id == current_user.id or
            message.conversation.to_user_id == current_user.id):
        abort(404)

    return format_quote(username=message.user.username,
                        content=message.message)
示例#5
0
def raw_message(message_id):
    message = Message.query.filter_by(id=message_id).first_or_404()

    # abort if the message was not the current_user's one or the one of the
    # recieved ones
    if not (message.conversation.from_user_id == current_user.id or
            message.conversation.to_user_id == current_user.id):
        abort(404)

    return format_quote(username=message.user.username,
                        content=message.message)
示例#6
0
文件: views.py 项目: justanr/flaskbb
    def get(self, topic_id, slug=None, post_id=None):
        topic = Topic.query.filter_by(id=topic_id).first_or_404()
        form = self.form()

        if post_id is not None:
            post = Post.query.filter_by(id=post_id).first_or_404()
            form.content.data = format_quote(post.username, post.content)

        return render_template(
            "forum/new_post.html", topic=topic, form=form
        )
示例#7
0
    def post(self, topic_id, post_id):
        form = self.form()
        topic = Topic.query.filter_by(id=topic_id).first_or_404()
        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(real(current_user), topic)
                return redirect(url_for('forum.view_post', post_id=post.id))
        else:
            form.content.data = format_quote(post.username, post.content)

        return render_template('forum/new_post.html', topic=post.topic, form=form)
示例#8
0
def reply_post(topic_id, post_id):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()
    post = Post.query.filter_by(id=post_id).first_or_404()

    if not Permission(CanPostReply):
        flash(_("You do not have the permissions to post in this 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:
            form.save(current_user, topic)
            return redirect(post.topic.url)
    else:
        form.content.data = format_quote(post.username, post.content)

    return render_template("forum/new_post.html", topic=post.topic, form=form)
示例#9
0
文件: views.py 项目: delida/flaskbb
def reply_post(topic_id, post_id):
    topic = Topic.query.filter_by(id=topic_id).first_or_404()
    post = Post.query.filter_by(id=post_id).first_or_404()

    if not can_post_reply(user=current_user, topic=topic):
        flash(_("You do not have the permissions to post in this 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:
            form.save(current_user, topic)
            return redirect(post.topic.url)
    else:
        form.content.data = format_quote(post)

    return render_template("forum/new_post.html", topic=post.topic, form=form)
示例#10
0
def raw_post(post_id):
    post = Post.query.filter_by(id=post_id).first_or_404()
    return format_quote(post)
示例#11
0
 def get(self, post_id):
     post = Post.query.filter_by(id=post_id).first_or_404()
     return format_quote(username=post.username, content=post.content)
示例#12
0
文件: views.py 项目: delida/flaskbb
def raw_post(post_id):
    post = Post.query.filter_by(id=post_id).first_or_404()
    return format_quote(username=post.username, content=post.content)
示例#13
0
def test_format_quote(topic):
    expected_markdown = "**[test_normal](http://localhost:5000/user/test_normal) wrote:**\n> Test Content Normal\n"  # noqa
    actual = format_quote(topic.first_post.username, topic.first_post.content)
    assert actual == expected_markdown
示例#14
0
def raw_post(post_id):
    post = Post.query.filter_by(id=post_id).first_or_404()
    return format_quote(post)
示例#15
0
def test_format_quote(topic):
    expected_markdown = "**[test_normal](http://localhost:5000/user/test_normal) wrote:**\n> Test Content Normal\n"  # noqa
    actual = format_quote(topic.first_post.username, topic.first_post.content)
    assert actual == expected_markdown