Ejemplo n.º 1
0
def test_topic_update_read(database, user, topic):
    """Tests the update read method if the topic is unread/read."""
    forumsread = ForumsRead.query.\
        filter(ForumsRead.user_id == user.id,
               ForumsRead.forum_id == topic.forum_id).first()

    with current_app.test_request_context():
        # Test with logged in user
        login_user(user)
        assert current_user.is_authenticated

        # Update the tracker
        assert topic.update_read(current_user, topic.forum, forumsread)
        # Because the tracker is already up-to-date, it shouldn't update it
        # again.
        assert not topic.update_read(current_user, topic.forum, forumsread)

        # Adding a new post - now the tracker shouldn't be up-to-date anymore.
        post = Post(content="Test Content")
        post.save(topic=topic, user=user)

        forumsread = ForumsRead.query.\
            filter(ForumsRead.user_id == user.id,
                   ForumsRead.forum_id == topic.forum_id).first()

        # Test tracker length
        flaskbb_config["TRACKER_LENGTH"] = 0
        assert not topic.update_read(current_user, topic.forum, forumsread)
        flaskbb_config["TRACKER_LENGTH"] = 1
        assert topic.update_read(current_user, topic.forum, forumsread)

        # Test with logged out user
        logout_user()
        assert not current_user.is_authenticated
        assert not topic.update_read(current_user, topic.forum, forumsread)
Ejemplo n.º 2
0
def test_post_delete(topic):
    """Tests the delete post method with three different post types.
    The three types are:
        * First Post
        * A post between the first and last post (middle)
        * Last Post
    """
    post_middle = Post(content="Test Content Middle")
    post_middle.save(topic=topic, user=topic.user)

    post_last = Post(content="Test Content Last")
    post_last.save(topic=topic, user=topic.user)

    assert topic.post_count == 3
    assert topic.forum.post_count == 3
    assert topic.user.post_count == 3

    post_middle.delete()

    # Check the last posts
    assert topic.last_post == post_last
    assert topic.forum.last_post == post_last

    post_last.delete()

    # That was a bit trickier..
    assert topic.post_count == 1
    assert topic.forum.post_count == 1
    assert topic.user.post_count == 1
    assert topic.first_post_id == topic.last_post_id

    assert topic.forum.last_post_id == topic.last_post_id
Ejemplo n.º 3
0
def insert_mass_data(topics=100, posts=100):
    """Creates 100 topics in the first forum and each topic has 100 posts.
    Returns ``True`` if the topics and posts were successfully created.

    :param topics: The amount of topics in the forum.
    :param posts: The number of posts in each topic.
    """
    user1 = User.query.filter_by(id=1).first()
    user2 = User.query.filter_by(id=2).first()
    forum = Forum.query.filter_by(id=1).first()

    if not user1 or user2 or forum:
        raise "Please make sure that there are at least 2 users and 1 forum."

    # create 1000 topics
    for i in range(1, topics + 1):

        # create a topic
        topic = Topic()
        post = Post()

        topic.title = "Test Title %s" % i
        post.content = "Test Content"
        topic.save(post=post, user=user1, forum=forum)

        # create 100 posts in each topic
        for j in range(1, posts):
            post = Post()
            post.content = "Test Post"
            post.save(user=user2, topic=topic)
Ejemplo n.º 4
0
def test_topic_update_read(database, user, topic):
    """Tests the update read method if the topic is unread/read."""
    forumsread = ForumsRead.query.\
        filter(ForumsRead.user_id == user.id,
               ForumsRead.forum_id == topic.forum_id).first()

    with current_app.test_request_context():
        # Test with logged in user
        login_user(user)
        assert current_user.is_authenticated

        # Update the tracker
        assert topic.update_read(current_user, topic.forum, forumsread)
        # Because the tracker is already up-to-date, it shouldn't update it
        # again.
        assert not topic.update_read(current_user, topic.forum, forumsread)

        # Adding a new post - now the tracker shouldn't be up-to-date anymore.
        post = Post(content="Test Content")
        post.save(topic=topic, user=user)

        forumsread = ForumsRead.query.\
            filter(ForumsRead.user_id == user.id,
                   ForumsRead.forum_id == topic.forum_id).first()

        # Test tracker length
        flaskbb_config["TRACKER_LENGTH"] = 0
        assert not topic.update_read(current_user, topic.forum, forumsread)
        flaskbb_config["TRACKER_LENGTH"] = 1
        assert topic.update_read(current_user, topic.forum, forumsread)

        # Test with logged out user
        logout_user()
        assert not current_user.is_authenticated
        assert not topic.update_read(current_user, topic.forum, forumsread)
Ejemplo n.º 5
0
def test_post_delete(topic):
    """Tests the delete post method with three different post types.
    The three types are:
        * First Post
        * A post between the first and last post (middle)
        * Last Post
    """
    post_middle = Post(content="Test Content Middle")
    post_middle.save(topic=topic, user=topic.user)
    assert topic.post_count == 2  # post_middle + first_post

    post_last = Post(content="Test Content Last")
    post_last.save(topic=topic, user=topic.user)

    # first post + post_middle + post_last
    assert topic.post_count == 3
    assert topic.forum.post_count == 3
    assert topic.user.post_count == 3

    post_middle.delete()

    # Check the last posts
    assert topic.last_post == post_last
    assert topic.forum.last_post == post_last
    assert topic.post_count == 2

    post_last.delete()

    # only the first_post remains
    assert topic.post_count == 1
    assert topic.forum.post_count == 1
    assert topic.user.post_count == 1
    assert topic.first_post_id == topic.last_post_id

    assert topic.forum.last_post_id == topic.last_post_id
Ejemplo n.º 6
0
def save_post_with_image_and_text(user, topic, image_url, text):
    post_content = ""
    post_content += text
    post_content += "\n"
    post_content += "\n"
    post_content += "![]({})".format(image_url)
    post = Post(content=post_content)
    post.save(user=user, topic=topic)
Ejemplo n.º 7
0
def test_retrieving_hidden_posts(topic, user):
    new_post = Post(content='stuff')
    new_post.save(user, topic)
    new_post.hide(user)

    assert Post.query.get(new_post.id) is None
    assert Post.query.get(new_post.id, include_hidden=True) == new_post
    assert Post.query.filter(Post.id == new_post.id).first() is None
    assert Post.query.with_hidden().filter(
        Post.id == new_post.id).first() == new_post
Ejemplo n.º 8
0
def test_forum_update_last_post(topic_normal, normal_user):
    post = Post(content="Test Content 2")
    post.save(topic=topic_normal, user=normal_user)

    assert topic_normal.forum.last_post == post

    post.delete()

    topic_normal.forum.update_last_post()

    assert topic_normal.forum.last_post == topic_normal.first_post
Ejemplo n.º 9
0
def test_forum_update_last_post(topic, user):
    """Test the update last post method."""
    post = Post(content="Test Content 2")
    post.save(topic=topic, user=user)

    assert topic.forum.last_post == post

    post.delete()

    topic.forum.update_last_post()

    assert topic.forum.last_post == topic.first_post
Ejemplo n.º 10
0
def test_forum_update_last_post(topic, user):
    """Test the update last post method."""
    post = Post(content="Test Content 2")
    post.save(topic=topic, user=user)

    assert topic.forum.last_post == post

    post.delete()

    topic.forum.update_last_post()

    assert topic.forum.last_post == topic.first_post
Ejemplo n.º 11
0
def test_forum_update_read(database, user, topic):
    """Test the update read method."""
    forumsread = ForumsRead.query.\
        filter(ForumsRead.user_id == user.id,
               ForumsRead.forum_id == topic.forum_id).first()

    topicsread = TopicsRead.query.\
        filter(TopicsRead.user_id == user.id,
               TopicsRead.topic_id == topic.id).first()

    forum = topic.forum

    with current_app.test_request_context():
        # Test with logged in user
        login_user(user)

        # Should return False because topicsread is None
        assert not forum.update_read(current_user, forumsread, topicsread)

        # This is the first time the user visits the topic
        topicsread = TopicsRead()
        topicsread.user_id = user.id
        topicsread.topic_id = topic.id
        topicsread.forum_id = topic.forum_id
        topicsread.last_read = datetime.utcnow()
        topicsread.save()

        # hence, we also need to create a new forumsread entry
        assert forum.update_read(current_user, forumsread, topicsread)

        forumsread = ForumsRead.query.\
            filter(ForumsRead.user_id == user.id,
                   ForumsRead.forum_id == topic.forum_id).first()

        # everything should be up-to-date now
        assert not forum.update_read(current_user, forumsread, topicsread)

        post = Post(content="Test Content")
        post.save(user=user, topic=topic)

        # Updating the topicsread tracker
        topicsread.last_read = datetime.utcnow()
        topicsread.save()

        # now the forumsread tracker should also need a update
        assert forum.update_read(current_user, forumsread, topicsread)

        logout_user()
        # should fail because the user is logged out
        assert not forum.update_read(current_user, forumsread, topicsread)
Ejemplo n.º 12
0
def test_forum_update_read(database, user, topic):
    """Test the update read method."""
    forumsread = ForumsRead.query.\
        filter(ForumsRead.user_id == user.id,
               ForumsRead.forum_id == topic.forum_id).first()

    topicsread = TopicsRead.query.\
        filter(TopicsRead.user_id == user.id,
               TopicsRead.topic_id == topic.id).first()

    forum = topic.forum

    with current_app.test_request_context():
        # Test with logged in user
        login_user(user)

        # Should return False because topicsread is None
        assert not forum.update_read(current_user, forumsread, topicsread)

        # This is the first time the user visits the topic
        topicsread = TopicsRead()
        topicsread.user_id = user.id
        topicsread.topic_id = topic.id
        topicsread.forum_id = topic.forum_id
        topicsread.last_read = datetime.utcnow()
        topicsread.save()

        # hence, we also need to create a new forumsread entry
        assert forum.update_read(current_user, forumsread, topicsread)

        forumsread = ForumsRead.query.\
            filter(ForumsRead.user_id == user.id,
                   ForumsRead.forum_id == topic.forum_id).first()

        # everything should be up-to-date now
        assert not forum.update_read(current_user, forumsread, topicsread)

        post = Post(content="Test Content")
        post.save(user=user, topic=topic)

        # Updating the topicsread tracker
        topicsread.last_read = datetime.utcnow()
        topicsread.save()

        # now the forumsread tracker should also need a update
        assert forum.update_read(current_user, forumsread, topicsread)

        logout_user()
        # should fail because the user is logged out
        assert not forum.update_read(current_user, forumsread, topicsread)
Ejemplo n.º 13
0
def create_test_data():
    """Creates 5 users, 2 categories and 2 forums in each category.
    It also creates a new topic topic in each forum with a post.
    """
    create_default_groups()
    create_default_settings()

    # create 5 users
    for u in range(1, 6):
        username = "******" % u
        email = "*****@*****.**" % u
        user = User(username=username, password="******", email=email)
        user.primary_group_id = u
        user.save()

    user1 = User.query.filter_by(id=1).first()
    user2 = User.query.filter_by(id=2).first()

    # create 2 categories
    for i in range(1, 3):
        category_title = "Test Category %s" % i
        category = Category(title=category_title,
                            description="Test Description")
        category.save()

        # create 2 forums in each category
        for j in range(1, 3):
            if i == 2:
                j += 2

            forum_title = "Test Forum %s %s" % (j, i)
            forum = Forum(title=forum_title,
                          description="Test Description",
                          category_id=i)
            forum.save()

            # create a topic
            topic = Topic()
            post = Post()

            topic.title = "Test Title %s" % j
            post.content = "Test Content"
            topic.save(post=post, user=user1, forum=forum)

            # create a second post in the forum
            post = Post()
            post.content = "Test Post"
            post.save(user=user2, topic=topic)
Ejemplo n.º 14
0
def create_test_data():
    """
    Creates 5 users, 2 categories and 2 forums in each category. It also opens
    a new topic topic in each forum with a post.
    """
    create_default_groups()
    create_default_settings()

    # create 5 users
    for u in range(1, 6):
        username = "******" % u
        email = "*****@*****.**" % u
        user = User(username=username, password="******", email=email)
        user.primary_group_id = u
        user.save()

    user1 = User.query.filter_by(id=1).first()
    user2 = User.query.filter_by(id=2).first()

    # create 2 categories
    for i in range(1, 3):
        category_title = "Test Category %s" % i
        category = Category(title=category_title,
                            description="Test Description")
        category.save()

        # create 2 forums in each category
        for j in range(1, 3):
            if i == 2:
                j += 2

            forum_title = "Test Forum %s %s" % (j, i)
            forum = Forum(title=forum_title, description="Test Description",
                          category_id=i)
            forum.save()

            # create a topic
            topic = Topic()
            post = Post()

            topic.title = "Test Title %s" % j
            post.content = "Test Content"
            topic.save(post=post, user=user1, forum=forum)

            # create a second post in the forum
            post = Post()
            post.content = "Test Post"
            post.save(user=user2, topic=topic)
Ejemplo n.º 15
0
class ReplyForm(PostForm):
    track_topic = BooleanField(_("Track this topic"),
                               default=False,
                               validators=[Optional()])

    def __init__(self, *args, **kwargs):
        self.post = kwargs.get("obj", None)
        PostForm.__init__(self, *args, **kwargs)

    def save(self, user, topic):
        # new post
        if self.post is None:
            self.post = Post(content=self.content.data)
        else:
            self.post.date_modified = time_utcnow()
            self.post.modified_by = user.username

        if self.track_topic.data:
            user.track_topic(topic)
        else:
            user.untrack_topic(topic)

        current_app.pluggy.hook.flaskbb_form_post_save(form=self,
                                                       post=self.post)
        return self.post.save(user=user, topic=topic)
Ejemplo n.º 16
0
def test_post_save(topic, user):
    """Tests the save post method."""
    post = Post(content="Test Content")
    post.save(topic=topic, user=user)

    assert post.content == "Test Content"

    post.content = "Test Edit Content"
    post.save()

    assert post.content == "Test Edit Content"

    assert topic.user.post_count == 2
    assert topic.post_count == 2
    assert topic.last_post == post
    assert topic.forum.post_count == 2
Ejemplo n.º 17
0
class ReplyForm(PostForm):
    track_topic = BooleanField(
        _("Track this topic"), default=False, validators=[Optional()]
    )

    def __init__(self, *args, **kwargs):
        self.post = kwargs.get("obj", None)
        PostForm.__init__(self, *args, **kwargs)

    def save(self, user, topic):
        # new post
        if self.post is None:
            self.post = Post(content=self.content.data)
        else:
            self.post.date_modified = time_utcnow()
            self.post.modified_by = user.username

        if self.track_topic.data:
            user.track_topic(topic)
        else:
            user.untrack_topic(topic)

        current_app.pluggy.hook.flaskbb_form_post_save(
            form=self, post=self.post
        )
        return self.post.save(user=user, topic=topic)
Ejemplo n.º 18
0
def test_post_save(topic, user):
    """Tests the save post method."""
    post = Post(content="Test Content")
    post.save(topic=topic, user=user)

    assert post.content == "Test Content"

    post.content = "Test Edit Content"
    post.save()

    assert post.content == "Test Edit Content"

    assert topic.user.post_count == 2
    assert topic.post_count == 2
    assert topic.last_post == post
    assert topic.forum.post_count == 2
Ejemplo n.º 19
0
    def save(self, user, topic):
        post = Post(content=self.content.data)

        if self.track_topic.data:
            user.track_topic(topic)

        current_app.pluggy.hook.flaskbb_form_new_post_save(form=self)
        return post.save(user=user, topic=topic)
Ejemplo n.º 20
0
    def save(self, user, topic):
        post = Post(content=self.content.data)

        if self.track_topic.data:
            user.track_topic(topic)

        current_app.pluggy.hook.flaskbb_form_new_post_save(form=self)
        return post.save(user=user, topic=topic)
Ejemplo n.º 21
0
def test_hiding_post_updates_counts(forum, topic, user):
    new_post = Post(content='spam')
    new_post.save(user=user, topic=topic)
    new_post.hide(user)
    assert user.post_count == 1
    assert topic.post_count == 1
    assert forum.post_count == 1
    assert topic.last_post != new_post
    assert forum.last_post != new_post
    assert new_post.hidden_by == user
    new_post.unhide()
    assert topic.post_count == 2
    assert user.post_count == 2
    assert forum.post_count == 2
    assert topic.last_post == new_post
    assert forum.last_post == new_post
    assert new_post.hidden_by is None
Ejemplo n.º 22
0
def insert_mass_data(topics=100, posts=100):
    """Creates a few topics in the first forum and each topic has
    a few posts. WARNING: This might take very long!
    Returns the count of created topics and posts.

    :param topics: The amount of topics in the forum.
    :param posts: The number of posts in each topic.
    """
    user1 = User.query.filter_by(id=1).first()
    user2 = User.query.filter_by(id=2).first()
    forum = Forum.query.filter_by(id=1).first()

    created_posts = 0
    created_topics = 0

    if not (user1 or user2 or forum):
        return False

    # create 1000 topics
    for i in range(1, topics + 1):

        # create a topic
        topic = Topic()
        post = Post()

        topic.title = "Test Title %s" % i
        post.content = "Test Content"
        topic.save(post=post, user=user1, forum=forum)
        created_topics += 1

        # create 100 posts in each topic
        for j in range(1, posts + 1):
            post = Post()
            post.content = "Test Post"
            post.save(user=user2, topic=topic)
            created_posts += 1

    return created_topics, created_posts
Ejemplo n.º 23
0
def insert_mass_data(topics=100, posts=100):
    """Creates a few topics in the first forum and each topic has
    a few posts. WARNING: This might take very long!
    Returns the count of created topics and posts.

    :param topics: The amount of topics in the forum.
    :param posts: The number of posts in each topic.
    """
    user1 = User.query.filter_by(id=1).first()
    user2 = User.query.filter_by(id=2).first()
    forum = Forum.query.filter_by(id=1).first()

    created_posts = 0
    created_topics = 0

    if not (user1 or user2 or forum):
        return False

    # create 1000 topics
    for i in range(1, topics + 1):

        # create a topic
        topic = Topic()
        post = Post()

        topic.title = "Test Title %s" % i
        post.content = "Test Content"
        topic.save(post=post, user=user1, forum=forum)
        created_topics += 1

        # create 100 posts in each topic
        for j in range(1, posts + 1):
            post = Post()
            post.content = "Test Post"
            post.save(user=user2, topic=topic)
            created_posts += 1

    return created_topics, created_posts
Ejemplo n.º 24
0
def test_topic_tracker_needs_update(database, user, topic):
    """Tests if the topicsread tracker needs an update if a new post has been
    submitted.
    """
    forumsread = ForumsRead.query.\
        filter(ForumsRead.user_id == user.id,
               ForumsRead.forum_id == topic.forum_id).first()

    topicsread = TopicsRead.query.\
        filter(TopicsRead.user_id == user.id,
               TopicsRead.topic_id == topic.id).first()

    with current_app.test_request_context():
        assert topic.tracker_needs_update(forumsread, topicsread)

        # Update the tracker
        topicsread = TopicsRead()
        topicsread.user_id = user.id
        topicsread.topic_id = topic.id
        topicsread.forum_id = topic.forum_id
        topicsread.last_read = datetime.utcnow()
        topicsread.save()

        forumsread = ForumsRead()
        forumsread.user_id = user.id
        forumsread.forum_id = topic.forum_id
        forumsread.last_read = datetime.utcnow()
        forumsread.save()

        # Now the topic should be read
        assert not topic.tracker_needs_update(forumsread, topicsread)

        post = Post(content="Test Content")
        post.save(topic=topic, user=user)

        assert topic.tracker_needs_update(forumsread, topicsread)
Ejemplo n.º 25
0
def insert_mass_data():
    """
    Creates 100 topics in the first forum and each topic has 100 posts.
    """
    user1 = User.query.filter_by(id=1).first()
    user2 = User.query.filter_by(id=2).first()
    forum = Forum.query.filter_by(id=1).first()

    # create 1000 topics
    for i in range(1, 101):

        # create a topic
        topic = Topic()
        post = Post()

        topic.title = "Test Title %s" % i
        post.content = "Test Content"
        topic.save(post=post, user=user1, forum=forum)

        # create 100 posts in each topic
        for j in range(1, 100):
            post = Post()
            post.content = "Test Post"
            post.save(user=user2, topic=topic)
Ejemplo n.º 26
0
def test_topic_tracker_needs_update(database, user, topic):
    """Tests if the topicsread tracker needs an update if a new post has been
    submitted.
    """
    forumsread = ForumsRead.query.\
        filter(ForumsRead.user_id == user.id,
               ForumsRead.forum_id == topic.forum_id).first()

    topicsread = TopicsRead.query.\
        filter(TopicsRead.user_id == user.id,
               TopicsRead.topic_id == topic.id).first()

    with current_app.test_request_context():
        assert topic.tracker_needs_update(forumsread, topicsread)

        # Update the tracker
        topicsread = TopicsRead()
        topicsread.user_id = user.id
        topicsread.topic_id = topic.id
        topicsread.forum_id = topic.forum_id
        topicsread.last_read = datetime.utcnow()
        topicsread.save()

        forumsread = ForumsRead()
        forumsread.user_id = user.id
        forumsread.forum_id = topic.forum_id
        forumsread.last_read = datetime.utcnow()
        forumsread.save()

        # Now the topic should be read
        assert not topic.tracker_needs_update(forumsread, topicsread)

        post = Post(content="Test Content")
        post.save(topic=topic, user=user)

        assert topic.tracker_needs_update(forumsread, topicsread)
Ejemplo n.º 27
0
    def save(self, user, topic):
        post = Post(content=self.content.data)

        if self.track_topic.data:
            user.track_topic(topic)
        return post.save(user=user, topic=topic)
Ejemplo n.º 28
0
 def save(self, user, topic):
     post = Post(**self.data)
     return post.save(user=user, topic=topic)
Ejemplo n.º 29
0
def create_test_data(users=5, categories=2, forums=2, topics=1, posts=1):
    """Creates 5 users, 2 categories and 2 forums in each category.
    It also creates a new topic topic in each forum with a post.
    Returns the amount of created users, categories, forums, topics and posts
    as a dict.

    :param users: The number of users.
    :param categories: The number of categories.
    :param forums: The number of forums which are created in each category.
    :param topics: The number of topics which are created in each forum.
    :param posts: The number of posts which are created in each topic.
    """
    create_default_groups()
    create_default_settings()

    data_created = {'users': 0, 'categories': 0, 'forums': 0,
                    'topics': 0, 'posts': 0}

    # create 5 users
    for u in range(1, users + 1):
        username = "******" % u
        email = "*****@*****.**" % u
        user = User(username=username, password="******", email=email)
        user.primary_group_id = u
        user.activated = True
        user.save()
        data_created['users'] += 1

    user1 = User.query.filter_by(id=1).first()
    user2 = User.query.filter_by(id=2).first()

    # lets send them a few private messages
    for i in range(1, 3):
        # TODO
        pass

    # create 2 categories
    for i in range(1, categories + 1):
        category_title = "Test Category %s" % i
        category = Category(title=category_title,
                            description="Test Description")
        category.save()
        data_created['categories'] += 1

        # create 2 forums in each category
        for j in range(1, forums + 1):
            if i == 2:
                j += 2

            forum_title = "Test Forum %s %s" % (j, i)
            forum = Forum(title=forum_title, description="Test Description",
                          category_id=i)
            forum.save()
            data_created['forums'] += 1

            for t in range(1, topics + 1):
                # create a topic
                topic = Topic(title="Test Title %s" % j)
                post = Post(content="Test Content")

                topic.save(post=post, user=user1, forum=forum)
                data_created['topics'] += 1

                for p in range(1, posts + 1):
                    # create a second post in the forum
                    post = Post(content="Test Post")
                    post.save(user=user2, topic=topic)
                    data_created['posts'] += 1

    return data_created
Ejemplo n.º 30
0
 def save(self, user, topic):
     post = Post(content=self.content.data)
     return post.save(user=user, topic=topic)
Ejemplo n.º 31
0
    def save(self, user, topic):
        post = Post(content=self.content.data)

        if self.track_topic.data:
            user.track_topic(topic)
        return post.save(user=user, topic=topic)
Ejemplo n.º 32
0
 def save(self, user, topic):
     post = Post(**self.data)
     return post.save(user=user, topic=topic)
Ejemplo n.º 33
0
 def save(self, user, topic):
     post = Post(content=self.content.data)
     return post.save(user=user, topic=topic)
Ejemplo n.º 34
0
def save_post(forum, user, topic, text_model):
    # Print three randomly-generated sentences of no more than 140 characters
    post_content = generate_body(text_model)
    post = Post(content=post_content)
    post.save(user=user, topic=topic)
Ejemplo n.º 35
0
 def save(self, user, topic):
     post = Post(content=self.content.data)
     current_app.pluggy.hook.flaskbb_form_post_save(form=self, post=post)
     return post.save(user=user, topic=topic)
Ejemplo n.º 36
0
 def save(self, user, topic):
     post = Post(content=self.content.data)
     current_app.pluggy.hook.flaskbb_form_post_save(form=self, post=post)
     return post.save(user=user, topic=topic)
Ejemplo n.º 37
0
def save_image_post_markov(forum, user, topic, text_model, image_url):
    post_content = generate_body(text_model)
    post_content += "![]({})".format(image_url)
    post = Post(content=post_content)
    post.save(user=user, topic=topic)