本文整理汇总了Python中the_tale.forum.prototypes.ThreadPrototype.get_new_thread_delay方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadPrototype.get_new_thread_delay方法的具体用法?Python ThreadPrototype.get_new_thread_delay怎么用?Python ThreadPrototype.get_new_thread_delay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.forum.prototypes.ThreadPrototype
的用法示例。
在下文中一共展示了ThreadPrototype.get_new_thread_delay方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_thread
# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import get_new_thread_delay [as 别名]
def create_thread(self):
if not can_create_thread(self.account, self.subcategory):
return self.json_error('forum.create_thread.no_permissions', 'Вы не можете создавать темы в данном разделе')
new_thread_delay = ThreadPrototype.get_new_thread_delay(self.account)
if new_thread_delay > 0:
error_message = ('Создавать новые обсуждения можно не чаще раза в %d минут.<br/> Вы сможете создать новое обсуждение через %d сек.' %
( int(forum_settings.THREAD_DELAY / 60),
int(new_thread_delay)))
return self.json_error('forum.create_thread.delay', error_message)
new_thread_form = forms.NewThreadForm(self.request.POST)
if not new_thread_form.is_valid():
return self.json_error('forum.create_thread.form_errors', new_thread_form.errors)
thread = ThreadPrototype.create(self.subcategory,
caption=new_thread_form.c.caption,
author=self.account,
text=new_thread_form.c.text)
return self.json_ok(data={'thread_url': reverse('forum:threads:show', args=[thread.id]),
'thread_id': thread.id})
示例2: test_get_new_thread_delay__has_new_thread
# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import get_new_thread_delay [as 别名]
def test_get_new_thread_delay__has_new_thread(self):
self.assertTrue(ThreadPrototype.get_new_thread_delay(self.account) > 0)
示例3: test_get_new_thread_delay__has_old_thread
# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import get_new_thread_delay [as 别名]
def test_get_new_thread_delay__has_old_thread(self):
ThreadPrototype._db_all().update(created_at=datetime.datetime.now() - datetime.timedelta(days=30))
self.assertEqual(ThreadPrototype.get_new_thread_delay(self.account), 0)
示例4: test_get_new_thread_delay__no_threads__old_account
# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import get_new_thread_delay [as 别名]
def test_get_new_thread_delay__no_threads__old_account(self):
new_account = self.accounts_factory.create_account()
new_account._model.created_at = datetime.datetime.now() - datetime.timedelta(days=30)
self.assertFalse(ThreadPrototype.get_new_thread_delay(new_account), 0)
示例5: test_get_new_thread_delay__no_threads__new_account
# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import get_new_thread_delay [as 别名]
def test_get_new_thread_delay__no_threads__new_account(self):
new_account = self.accounts_factory.create_account()
self.assertTrue(ThreadPrototype.get_new_thread_delay(new_account) > 0)
示例6: test_get_new_thread_delay__no_threads__old_account
# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import get_new_thread_delay [as 别名]
def test_get_new_thread_delay__no_threads__old_account(self):
register_user('new_test_user', '[email protected]', '111111')
new_account = AccountPrototype.get_by_nick('new_test_user')
new_account._model.created_at = datetime.datetime.now() - datetime.timedelta(days=30)
self.assertFalse(ThreadPrototype.get_new_thread_delay(new_account), 0)
示例7: test_get_new_thread_delay__no_threads__new_account
# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import get_new_thread_delay [as 别名]
def test_get_new_thread_delay__no_threads__new_account(self):
register_user('new_test_user', '[email protected]', '111111')
new_account = AccountPrototype.get_by_nick('new_test_user')
self.assertTrue(ThreadPrototype.get_new_thread_delay(new_account) > 0)