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


Python Post.on_moderation方法代码示例

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


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

示例1: save

# 需要导入模块: from pybb.models import Post [as 别名]
# 或者: from pybb.models.Post import on_moderation [as 别名]
 def save(self, commit=True):
     if self.instance.pk:
         post = super(PostForm, self).save(commit=False)
         if self.user:
             post.user = self.user
         if post.topic.head == post:
             post.topic.name = self.cleaned_data['name']
             post.topic.updated = datetime.now()
             post.topic.save()
         post.save()
         return post
     allow_post = True
     if defaults.PYBB_PREMODERATION:
             allow_post = defaults.PYBB_PREMODERATION(self.user, self.cleaned_data['body'])
     if self.forum:
         topic = Topic(forum=self.forum,
                       user=self.user,
                       name=self.cleaned_data['name'])
         if not allow_post:
             topic.on_moderation = True
         topic.save()
     else:
         topic = self.topic
     post = Post(topic=topic, user=self.user, user_ip=self.ip,
                 body=self.cleaned_data['body'])
     if not allow_post:
         post.on_moderation = True
     post.save()
     return post
开发者ID:makinacorpus,项目名称:pybbm,代码行数:31,代码来源:forms.py

示例2: save

# 需要导入模块: from pybb.models import Post [as 别名]
# 或者: from pybb.models.Post import on_moderation [as 别名]
    def save(self, commit=True):
        if self.instance.pk:
            post = super(PostForm, self).save(commit=False)
            if self.user:
                post.user = self.user
            if post.topic.head == post:
                post.topic.name = self.cleaned_data['name']
                if self.may_create_poll:
                    post.topic.poll_type = self.cleaned_data['poll_type']
                    post.topic.poll_question = self.cleaned_data['poll_question']
                post.topic.updated = tznow()
                if commit:
                    post.topic.save()
            post.updated = tznow()
            if commit:
                post.save()
            return post, post.topic

        allow_post = True
        if defaults.PYBB_PREMODERATION:
            allow_post = defaults.PYBB_PREMODERATION(self.user, self.cleaned_data['body'])
        if self.forum:
            topic = Topic(
                forum=self.forum,
                user=self.user,
                name=self.cleaned_data['name'],
                poll_type=self.cleaned_data.get('poll_type', Topic.POLL_TYPE_NONE),
                poll_question=self.cleaned_data.get('poll_question', None),
                slug=self.cleaned_data.get('slug', None),
            )
            if not allow_post:
                topic.on_moderation = True
        else:
            topic = self.topic
        post = Post(user=self.user, user_ip=self.ip, body=self.cleaned_data['body'])
        if not allow_post:
            post.on_moderation = True
        if commit:
            topic.save()
            post.topic = topic
            post.save()
        return post, topic
开发者ID:DylannCordel,项目名称:pybbm,代码行数:44,代码来源:forms.py


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