• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python prototypes.SubCategoryReadInfoPrototype类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_success

 def test_success(self):
     self.check_ajax_ok(self.client.post(url('forum:read-all-in-subcategory', self.subcat1.id)))
     self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 1)
     read_info = SubCategoryReadInfoPrototype._db_get_object(0)
     self.assertEqual(read_info.account_id, self.account.id)
     self.assertEqual(read_info.subcategory_id, self.subcat1.id)
     self.assertTrue(read_info.all_read_at > datetime.datetime.now() - datetime.timedelta(seconds=1))
开发者ID:Alkalit,项目名称:the-tale,代码行数:7,代码来源:test_requests.py


示例2: get_subcategory

    def get_subcategory(self, page=1):

        threads_query = Thread.objects.filter(subcategory=self.subcategory._model)

        url_builder = UrlBuilder(reverse('forum:subcategories:show', args=[self.subcategory.id]), arguments={'page': page})

        page -= 1

        paginator = Paginator(page, threads_query.count(), forum_settings.THREADS_ON_PAGE, url_builder)

        if paginator.wrong_page_number:
            return self.redirect(paginator.last_page_url, permanent=False)

        thread_from, thread_to = paginator.page_borders(page)

        threads = ThreadPrototype.from_query(threads_query.select_related().order_by('-important', '-updated_at')[thread_from:thread_to])

        important_threads = sorted([t for t in threads if t.important], key=lambda t: t.caption)
        threads = [t for t in threads if not t.important]

        read_state = ReadState(account=self.account)

        if self.account.is_authenticated:
            SubCategoryReadInfoPrototype.read_subcategory(subcategory=self.subcategory, account=self.account)

        return self.template('forum/subcategory.html',
                             {'category': self.category,
                              'subcategory': self.subcategory,
                              'can_create_thread': can_create_thread(self.account, self.subcategory),
                              'paginator': paginator,
                              'can_subscribe': self.account.is_authenticated and not self.account.is_fast,
                              'has_subscription': SubscriptionPrototype.has_subscription(self.account, subcategory=self.subcategory),
                              'threads': threads,
                              'important_threads': important_threads,
                              'read_state': read_state } )
开发者ID:,项目名称:,代码行数:35,代码来源:


示例3: test_thread_has_new_messages__category_read

    def test_thread_has_new_messages__category_read(self):
        read_state = self.get_read_state()
        self.assertTrue(read_state.thread_is_new(self.thread))

        SubCategoryReadInfoPrototype.read_all_in_subcategory(self.subcategory, self.account)
        read_state = self.get_read_state()

        self.assertFalse(read_state.thread_has_new_messages(self.thread))
开发者ID:,项目名称:,代码行数:8,代码来源:


示例4: test_read_all_in_subcategory__unexisted_info

 def test_read_all_in_subcategory__unexisted_info(self):
     self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 0)
     read_info = SubCategoryReadInfoPrototype.read_all_in_subcategory(self.subcategory, self.account)
     self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 1)
     self.assertEqual(read_info.subcategory_id, self.subcategory.id)
     self.assertEqual(read_info.account_id, self.account.id)
     self.assertTrue(read_info.read_at > datetime.datetime.now() - datetime.timedelta(seconds=1))
     self.assertTrue(read_info.all_read_at > datetime.datetime.now() - datetime.timedelta(seconds=1))
开发者ID:,项目名称:,代码行数:8,代码来源:


示例5: test_subcategory_has_new_messages__new_post_from_request_from_read_account

    def test_subcategory_has_new_messages__new_post_from_request_from_read_account(self):
        SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
        self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))

        self.request_login(self.account.email)
        self.client.post(url('forum:threads:create-post', self.thread.id), {'text': 'thread3-test-post'})

        self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
开发者ID:,项目名称:,代码行数:8,代码来源:


示例6: test_subcategory_has_new_messages__unread_but_thread_read

 def test_subcategory_has_new_messages__unread_but_thread_read(self):
     SubCategoryReadInfoPrototype.read_subcategory(subcategory=self.subcategory, account=self.account)
     self.subcategory._model.updated_at = datetime.datetime.now()
     self.subcategory.save()
     self.assertTrue(self.get_read_state().subcategory_has_new_messages(self.subcategory))
     ThreadReadInfoPrototype.read_thread(self.thread, self.account)
     ThreadReadInfoPrototype.read_thread(self.thread_2, self.account)
     ThreadReadInfoPrototype.read_thread(self.thread_3, self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
开发者ID:,项目名称:,代码行数:9,代码来源:


示例7: handle

    def handle(self, *args, **options):
        from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype
        from the_tale.forum.prototypes import SubCategoryReadInfoPrototype, ThreadReadInfoPrototype
        from the_tale.post_service.prototypes import MessagePrototype

        PostponedTaskPrototype.remove_old_tasks()

        ThreadReadInfoPrototype.remove_old_infos()
        SubCategoryReadInfoPrototype.remove_old_infos()

        MessagePrototype.remove_old_messages()
开发者ID:lshestov,项目名称:the-tale,代码行数:11,代码来源:portal_clean.py


示例8: test_thread_is_new__read

    def test_thread_is_new__read(self):
        SubCategoryReadInfoPrototype.read_subcategory(self.subcategory, self.account)

        read_state = self.get_read_state()

        self.assertFalse(read_state.thread_is_new(self.thread))

        self.thread._model.created_at = datetime.datetime.now()
        self.thread.save()

        self.assertTrue(read_state.thread_is_new(self.thread))
开发者ID:,项目名称:,代码行数:11,代码来源:


示例9: test_subcategory

    def test_subcategory(self):
        self.request_logout()
        self.request_login(self.account_2.email)

        self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 0)

        texts = ['cat1-caption', 'subcat1-caption', 'thread1-caption', 'thread2-caption', 'pgf-new-thread-marker', self.fixture.clan_1.abbr]
        self.check_html_ok(self.request_html(url('forum:subcategories:show', self.subcat1.id)), texts=texts)

        self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 1)

        read_info = SubCategoryReadInfoPrototype._db_get_object(0)
        self.assertEqual(read_info.account_id, self.account_2.id)
        self.assertEqual(read_info.subcategory_id, self.subcat1.id)

        self.check_html_ok(self.request_html(url('forum:subcategories:show', self.subcat1.id)), texts=[('pgf-new-thread-marker', 0)])
开发者ID:Alkalit,项目名称:the-tale,代码行数:16,代码来源:test_requests.py


示例10: test_remove_old_infos

    def test_remove_old_infos(self):
        read_info_1 = SubCategoryReadInfoPrototype.read_subcategory(self.subcategory, self.account)
        read_info_2 = SubCategoryReadInfoPrototype.read_subcategory(self.subcategory, self.account_2)

        removed_time = datetime.datetime.now() - datetime.timedelta(seconds=forum_settings.UNREAD_STATE_EXPIRE_TIME)
        SubCategoryReadInfoPrototype._model_class.objects.filter(id=read_info_2.id).update(read_at=removed_time)

        self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 2)
        SubCategoryReadInfoPrototype.remove_old_infos()
        self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 1)
        self.assertEqual(SubCategoryReadInfoPrototype._db_get_object(0).id, read_info_1.id)
开发者ID:,项目名称:,代码行数:11,代码来源:


示例11: get_subcategories_read_info

    def get_subcategories_read_info(self):
        if not self._account.is_authenticated():
            return {}

        return SubCategoryReadInfoPrototype.get_subcategories_info(account_id=self._account.id)
开发者ID:Alkalit,项目名称:the-tale,代码行数:5,代码来源:read_state.py


示例12: test_subcategory_has_new_messages__read_all

 def test_subcategory_has_new_messages__read_all(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
开发者ID:,项目名称:,代码行数:3,代码来源:


示例13: test_create_when_created

    def test_create_when_created(self):
        read_info_1 = SubCategoryReadInfoPrototype.read_subcategory(self.subcategory, self.account)
        read_info_2 = SubCategoryReadInfoPrototype.read_subcategory(self.subcategory, self.account)

        self.assertEqual(read_info_1.id, read_info_2.id)
开发者ID:,项目名称:,代码行数:5,代码来源:


示例14: test_unlogined

 def test_unlogined(self):
     self.request_logout()
     self.check_ajax_error(self.client.post(url('forum:read-all')), 'common.login_required')
     self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 0)
开发者ID:Alkalit,项目名称:the-tale,代码行数:4,代码来源:test_requests.py


示例15: test_subcategory_has_new_messages__unread_state_expired

    def test_subcategory_has_new_messages__unread_state_expired(self):
        SubCategoryReadInfoPrototype.read_subcategory(subcategory=self.subcategory, account=self.account)
        self.subcategory._model.updated_at = datetime.datetime.now()
        self.subcategory.save()

        self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
开发者ID:,项目名称:,代码行数:6,代码来源:


示例16: test_subcategory__unlogined

    def test_subcategory__unlogined(self):
        texts = ['cat1-caption', 'subcat1-caption', 'thread1-caption', 'thread2-caption', self.fixture.clan_1.abbr]
        self.request_logout()
        self.check_html_ok(self.request_html(url('forum:subcategories:show', self.subcat1.id)), texts=texts)

        self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 0)
开发者ID:Alkalit,项目名称:the-tale,代码行数:6,代码来源:test_requests.py


示例17: read_all__all

 def read_all__all(self):
     for subcategory in SubCategoryPrototype.subcategories_visible_to_account(account=self.account):
         SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=subcategory, account=self.account)
     return self.json_ok()
开发者ID:,项目名称:,代码行数:4,代码来源:


示例18: read_all__one

 def read_all__one(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
     return self.json_ok()
开发者ID:,项目名称:,代码行数:3,代码来源:


示例19: test_subcategory_has_new_messages__new_thread

 def test_subcategory_has_new_messages__new_thread(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
     ThreadPrototype.create(self.subcategory, 'new-threwad', self.account_2, 'thread-new-text')
     self.assertTrue(self.get_read_state().subcategory_has_new_messages(self.subcategory))
开发者ID:,项目名称:,代码行数:5,代码来源:


示例20: test_subcategory_expired__no_read_info

 def test_subcategory_expired__no_read_info(self):
     SubCategoryReadInfoPrototype._db_all().delete()
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
开发者ID:,项目名称:,代码行数:3,代码来源:



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python prototypes.ThreadPrototype类代码示例发布时间:2022-05-27
下一篇:
Python prototypes.SubCategoryPrototype类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap