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


Python ThreadPrototype.from_query方法代码示例

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


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

示例1: threads_info

# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import from_query [as 别名]
    def threads_info(self):
        if not self._account.is_authenticated():
            return {}

        time_barrier = datetime.datetime.now() - datetime.timedelta(seconds=forum_settings.UNREAD_STATE_EXPIRE_TIME)

        return {thread.id: thread for thread in ThreadPrototype.from_query(ThreadPrototype._db_filter(updated_at__gt=time_barrier))}
开发者ID:Alkalit,项目名称:the-tale,代码行数:9,代码来源:read_state.py

示例2: get_subcategory

# 需要导入模块: from the_tale.forum.prototypes import ThreadPrototype [as 别名]
# 或者: from the_tale.forum.prototypes.ThreadPrototype import from_query [as 别名]
    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:,项目名称:,代码行数:37,代码来源:


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