def create_forum_topic(article, forum_name):
    if article.id == None:
        # forum topic not created, lets create
        user = get_object_or_404(User,
                                 username=threadlocals.get_current_user())
        forum = Forum.objects.filter(name=forum_name).order_by("id")[0]
        topic = Topic(
            forum=forum,
            title=article.title,
        )
        topic.save()

        post = Post(
            topic=topic,
            author=user,
            text=article.text,
            ip=threadlocals.get_current_ip(),
            hidden=not article.status,
        )
        post.save()

        topic.topic_latest_post = post
        topic.posts = 1
        topic.hidden = not article.status
        topic.topic_latest_post = post
        topic.forum.posts += 1
        topic.forum.topics += 1
        if article.status:
            topic.forum.forum_latest_post = post
        topic.forum.save()
        topic.save()
        article.topic = topic
    else:
        # this is modified, let's update the forum topic
        topic = article.topic
        topic.tags.clear()
        for tag in article.tags.all():
            topic.tags.add(tag)

        topic.hidden = not article.status
        topic.locked = not article.status
        topic.title = article.title
        topic.save()

        post = topic.post_set.order_by("created")[0]
        post.text = article.text
        post.hidden = not article.status
        post.edited = article.update
        post.save()
    if article.status:
        try:
            ping_google()
        # we're catching SitemapNotFound exception
        # no need to import this exception class since there is only 1 exception in the function.
        except:
            pass
Exemple #2
0
def create_forum_topic(article, forum_name):
    if article.id == None:
        # forum topic not created, lets create
        user = get_object_or_404(User, username=threadlocals.get_current_user())
        forum = Forum.objects.filter(name=forum_name).order_by("id")[0]
        topic = Topic(
                forum = forum,
                title = article.title,
                )
        topic.save()

        post = Post(
                topic=topic,
                author=user,
                text=article.text,
                ip=threadlocals.get_current_ip(),
                hidden=not article.status,
                )
        post.save()

        topic.topic_latest_post = post
        topic.posts = 1
        topic.hidden = not article.status
        topic.topic_latest_post = post
        topic.forum.posts += 1
        topic.forum.topics += 1
        if article.status:
            topic.forum.forum_latest_post = post
        topic.forum.save()
        topic.save()
        article.topic = topic
    else:
        # this is modified, let's update the forum topic
        topic = article.topic
        topic.tags.clear()
        for tag in article.tags.all():
            topic.tags.add(tag)

        topic.hidden = not article.status
        topic.locked = not article.status
        topic.title = article.title
        topic.save()

        post = topic.post_set.order_by("created")[0]
        post.text = article.text
        post.hidden = not article.status
        post.edited = article.update
        post.save()
    if article.status:
        try:
            ping_google()
        # we're catching SitemapNotFound exception
        # no need to import this exception class since there is only 1 exception in the function.
        except:
            pass
Exemple #3
0
 def save(self):
     self.author = threadlocals.get_current_user()
     super(FlatPage, self).save()
Exemple #4
0
 def save(self):
     self.author = threadlocals.get_current_user()
     super(FlatPage, self).save()