当前位置: 首页>>代码示例>>Python>>正文


Python Thread.get_absolute_url方法代码示例

本文整理汇总了Python中misago.threads.models.Thread.get_absolute_url方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.get_absolute_url方法的具体用法?Python Thread.get_absolute_url怎么用?Python Thread.get_absolute_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在misago.threads.models.Thread的用法示例。


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

示例1: action_split

# 需要导入模块: from misago.threads.models import Thread [as 别名]
# 或者: from misago.threads.models.Thread import get_absolute_url [as 别名]
    def action_split(self, request, posts):
        if posts[0].id == self.thread.first_post_id:
            message = _("You can't split thread's first post.")
            raise moderation.ModerationError(message)

        form = SplitThreadForm(acl=request.user.acl)

        if 'submit' in request.POST or 'follow' in request.POST:
            form = SplitThreadForm(request.POST, acl=request.user.acl)
            if form.is_valid():
                split_thread = Thread()
                split_thread.forum = form.cleaned_data['forum']
                split_thread.set_title(
                    form.cleaned_data['thread_title'])
                split_thread.starter_name = "-"
                split_thread.starter_slug = "-"
                split_thread.last_poster_name = "-"
                split_thread.last_poster_slug = "-"
                split_thread.started_on = timezone.now()
                split_thread.last_post_on = timezone.now()
                split_thread.save()

                for post in posts:
                    post.move(split_thread)
                    post.save()

                split_thread.synchronize()
                split_thread.save()

                if split_thread.forum != self.forum:
                    split_thread.forum.lock()
                    split_thread.forum.synchronize()
                    split_thread.forum.save()

                changed_posts = len(posts)
                message = ungettext(
                    '%(changed)d post was split to "%(thread)s".',
                    '%(changed)d posts were split to "%(thread)s".',
                changed_posts)
                messages.success(request, message % {
                    'changed': changed_posts,
                    'thread': split_thread.title
                })

                if 'follow' in request.POST:
                    return redirect(split_thread.get_absolute_url())
                else:
                    return None # trigger thread refresh

        if request.is_ajax():
            template = self.split_thread_modal_template
        else:
            template = self.split_thread_full_template

        return render(request, template, {
            'form': form,
            'forum': self.forum,
            'thread': self.thread,
            'path': get_forum_path(self.forum),

            'posts': posts
        })
开发者ID:Backenkoehler,项目名称:Misago,代码行数:64,代码来源:postsactions.py


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