本文整理汇总了Python中kitsune.questions.models.Question.save方法的典型用法代码示例。如果您正苦于以下问题:Python Question.save方法的具体用法?Python Question.save怎么用?Python Question.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kitsune.questions.models.Question
的用法示例。
在下文中一共展示了Question.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_no_inactive_users
# 需要导入模块: from kitsune.questions.models import Question [as 别名]
# 或者: from kitsune.questions.models.Question import save [as 别名]
def test_no_inactive_users(self):
"""Ensure that inactive users' questions don't appear in the feed."""
u = user(is_active=False, save=True)
q = Question(title='Test Question', content='Lorem Ipsum Dolor',
creator_id=u.id)
q.save()
assert q.id not in [x.id for x in QuestionsFeed().items({})]
示例2: test_notification_created
# 需要导入模块: from kitsune.questions.models import Question [as 别名]
# 或者: from kitsune.questions.models.Question import save [as 别名]
def test_notification_created(self):
"""Creating a new question auto-watches it for answers."""
u = User.objects.get(pk=118533)
q = Question(creator=u, title='foo', content='bar')
q.save()
assert QuestionReplyEvent.is_notifying(u, q)
示例3: test_no_inactive_users
# 需要导入模块: from kitsune.questions.models import Question [as 别名]
# 或者: from kitsune.questions.models.Question import save [as 别名]
def test_no_inactive_users(self):
"""Ensure that inactive users' questions don't appear in the feed."""
u = User.objects.get(pk=118533)
u.is_active = False
u.save()
q = Question(title='Test Question', content='Lorem Ipsum Dolor',
creator_id=118533)
q.save()
assert q.id not in [x.id for x in QuestionsFeed().items()]
示例4: question
# 需要导入模块: from kitsune.questions.models import Question [as 别名]
# 或者: from kitsune.questions.models.Question import save [as 别名]
def question(save=False, **kwargs):
defaults = dict(title=str(datetime.now()),
content='',
created=datetime.now(),
num_answers=0,
is_locked=0)
defaults.update(kwargs)
if 'creator' not in kwargs and 'creator_id' not in kwargs:
defaults['creator'] = profile().user
q = Question(**defaults)
if save:
q.save()
if 'metadata' in defaults:
if not save:
raise ValueError('save must be True if metadata provided.')
q.add_metadata(**defaults['metadata'])
return q