本文整理匯總了Python中pybb.models.Topic.on_moderation方法的典型用法代碼示例。如果您正苦於以下問題:Python Topic.on_moderation方法的具體用法?Python Topic.on_moderation怎麽用?Python Topic.on_moderation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pybb.models.Topic
的用法示例。
在下文中一共展示了Topic.on_moderation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: save
# 需要導入模塊: from pybb.models import Topic [as 別名]
# 或者: from pybb.models.Topic 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
示例2: get_or_create_topic
# 需要導入模塊: from pybb.models import Topic [as 別名]
# 或者: from pybb.models.Topic import on_moderation [as 別名]
def get_or_create_topic(self, allow_post):
if self._forum:
topic = Topic(
forum=self._forum,
user=self.user,
name=self.cleaned_data['name'],
)
if not allow_post:
topic.on_moderation = topic.MODERATION_IS_IN_MODERATION
topic.save()
if not defaults.PYBB_DISABLE_POLLS:
if 'poll_type' in self.cleaned_data and self.cleaned_data['poll_type'] != Poll.TYPE_NONE:
poll = Poll(
type=self.cleaned_data['poll_type'],
question=self.cleaned_data['poll_question']
)
poll.save()
topic.poll = poll
else:
topic = self._topic
return topic
示例3: save
# 需要導入模塊: from pybb.models import Topic [as 別名]
# 或者: from pybb.models.Topic 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