Esempio n. 1
0
 async def get(self, *, page: int=1):
   # TODO(iceboy): continuation based pagination.
   nodes, (ddocs, dpcount, _) = await asyncio.gather(
       discussion.get_nodes(self.domain_id),
       # TODO(twd2): exclude problem/contest discussions?
       pagination.paginate(discussion.get_multi(self.domain_id), page, self.DISCUSSIONS_PER_PAGE))
   udict, vndict = await asyncio.gather(
       user.get_dict(ddoc['owner_uid'] for ddoc in ddocs),
       discussion.get_dict_vnodes(self.domain_id, map(discussion.node_id, ddocs)))
   self.render('discussion_main_or_node.html', discussion_nodes=nodes, ddocs=ddocs,
               udict=udict, vndict=vndict, page=page, dpcount=dpcount)
Esempio n. 2
0
 async def get(self, *, page: int = 1):
   # TODO(iceboy): continuation based pagination.
   skip = (page - 1) * self.DISCUSSIONS_PER_PAGE
   limit = self.DISCUSSIONS_PER_PAGE
   nodes, ddocs, dcount = await asyncio.gather(discussion.get_nodes(self.domain_id),
                                               discussion.get_list(self.domain_id,
                                                                   skip=skip,
                                                                   limit=limit),
                                               discussion.count(self.domain_id))
   self.render('discussion_main_or_node.html', discussion_nodes=nodes, ddocs=ddocs,
               page=page, dcount=dcount)
Esempio n. 3
0
 async def get(self, *, node_or_pid: document.convert_doc_id, page: int = 1):
   # TODO(iceboy): continuation based pagination.
   nodes, (vnode, ddocs, dcount) = await asyncio.gather(
     discussion.get_nodes(self.domain_id),
     discussion.get_vnode_and_list_and_count_for_node(
       self.domain_id, node_or_pid,
       skip=(page - 1) * self.DISCUSSIONS_PER_PAGE, limit=self.DISCUSSIONS_PER_PAGE))
   path_components = self.build_path(
     (self.translate('discussion_main'), self.reverse_url('discussion_main')),
     (vnode['title'], None))
   self.render('discussion_main_or_node.html', discussion_nodes=nodes, vnode=vnode, ddocs=ddocs,
               page=page, dcount=dcount, path_components=path_components)
Esempio n. 4
0
 async def get(self, *, page: int=1):
   # TODO(iceboy): continuation based pagination.
   nodes, (ddocs, dpcount, _) = await asyncio.gather(
       discussion.get_nodes(self.domain_id),
       # TODO(twd2): exclude problem/contest discussions?
       pagination.paginate(discussion.get_multi(self.domain_id), page, self.DISCUSSIONS_PER_PAGE))
   udict, dudict, vndict = await asyncio.gather(
       user.get_dict(ddoc['owner_uid'] for ddoc in ddocs),
       domain.get_dict_user_by_uid(domain_id=self.domain_id, uids=(ddoc['owner_uid'] for ddoc in ddocs)),
       discussion.get_dict_vnodes(self.domain_id, map(discussion.node_id, ddocs)))
   self.render('discussion_main_or_node.html', discussion_nodes=nodes, ddocs=ddocs,
               udict=udict, dudict=dudict, vndict=vndict, page=page, dpcount=dpcount)