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


Python PostPrototype.get_new_post_delay方法代码示例

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


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

示例1: test_get_new_post_delay__more_then_one_post

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
    def test_get_new_post_delay__more_then_one_post(self):
        PostPrototype.create(thread=self.thread, author=self.account, text='post-1-text')
        delay_1 = PostPrototype.get_new_post_delay(self.account)

        PostPrototype.create(thread=self.thread, author=self.account, text='post-1-text')

        delay_2 = PostPrototype.get_new_post_delay(self.account)

        self.assertTrue(delay_1 - delay_2 > 1)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: create_post

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
    def create_post(self):

        new_post_delay = PostPrototype.get_new_post_delay(self.account)

        if new_post_delay > 0:
            error_message = ('Создавать новые сообщения можно не чаще раза в %d секунд. <br/>Задержка увеличивается для игроков, только начинающих общаться на форуме.<br/> Вы сможете создать новое сообщение через %d сек.' %
                             ( forum_settings.POST_DELAY,
                               int(new_post_delay)))
            return self.json_error('forum.create_post.delay', error_message)


        new_post_form = forms.NewPostForm(self.request.POST)

        if not new_post_form.is_valid():
            return self.json_error('forum.create_post.form_errors', new_post_form.errors)

        post = PostPrototype.create(self.thread, self.account, new_post_form.c.text)

        if self.account.is_authenticated:
            ThreadReadInfoPrototype.read_thread(self.thread, self.account)

        return self.json_ok(data={'next_url': url('forum:threads:show', self.thread.id, page=self.thread.paginator.pages_count) + ('#m%d' % post.id)})
开发者ID:,项目名称:,代码行数:24,代码来源:

示例3: test_get_new_post_delay__a_lot_of_posts

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
    def test_get_new_post_delay__a_lot_of_posts(self):
        for i in range(100):
            PostPrototype.create(thread=self.thread, author=self.account, text='post-1-text')

        self.assertTrue(PostPrototype.get_new_post_delay(self.account) < forum_settings.POST_DELAY)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: test_get_new_post_delay__has_new_post

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
 def test_get_new_post_delay__has_new_post(self):
     PostPrototype.create(thread=self.thread, author=self.account, text='post-1-text')
     self.assertTrue(PostPrototype.get_new_post_delay(self.account) > 0)
开发者ID:,项目名称:,代码行数:5,代码来源:

示例5: test_get_new_post_delay__has_old_post

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
 def test_get_new_post_delay__has_old_post(self):
     PostPrototype.create(thread=self.thread, author=self.account, text='post-1-text')
     PostPrototype._db_all().update(created_at=datetime.datetime.now() - datetime.timedelta(days=30))
     self.assertEqual(PostPrototype.get_new_post_delay(self.account), 0)
开发者ID:,项目名称:,代码行数:6,代码来源:

示例6: test_get_new_post_delay__no_posts__old_account

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
 def test_get_new_post_delay__no_posts__old_account(self):
     new_account = self.accounts_factory.create_account()
     new_account._model.created_at = datetime.datetime.now() - datetime.timedelta(days=30)
     self.assertFalse(PostPrototype.get_new_post_delay(new_account), 0)
开发者ID:,项目名称:,代码行数:6,代码来源:

示例7: test_get_new_post_delay__no_posts__new_account

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
 def test_get_new_post_delay__no_posts__new_account(self):
     new_account = self.accounts_factory.create_account()
     self.assertTrue(PostPrototype.get_new_post_delay(new_account) > 0)
开发者ID:,项目名称:,代码行数:5,代码来源:

示例8: test_get_new_post_delay__no_posts__old_account

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
 def test_get_new_post_delay__no_posts__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(PostPrototype.get_new_post_delay(new_account), 0)
开发者ID:Alkalit,项目名称:the-tale,代码行数:7,代码来源:test_prototypes.py

示例9: test_get_new_post_delay__no_posts__new_account

# 需要导入模块: from the_tale.forum.prototypes import PostPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.PostPrototype import get_new_post_delay [as 别名]
 def test_get_new_post_delay__no_posts__new_account(self):
     register_user('new_test_user', '[email protected]', '111111')
     new_account = AccountPrototype.get_by_nick('new_test_user')
     self.assertTrue(PostPrototype.get_new_post_delay(new_account) > 0)
开发者ID:Alkalit,项目名称:the-tale,代码行数:6,代码来源:test_prototypes.py


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