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


Python ThreadPrototype.get_new_thread_delay方法代码示例

本文整理汇总了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})
开发者ID:,项目名称:,代码行数:26,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:4,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:5,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:6,代码来源:

示例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)
开发者ID:,项目名称:,代码行数:5,代码来源:

示例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)
开发者ID:Alkalit,项目名称:the-tale,代码行数:7,代码来源:test_prototypes.py

示例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)
开发者ID:Alkalit,项目名称:the-tale,代码行数:6,代码来源:test_prototypes.py


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