def _process_doc(self, doc): ui_doc = dict(doc) if doc.get('product'): env = ProductEnvironment(self.env, doc['product']) product_href = ProductEnvironment.resolve_href(env, self.env) ui_doc["href"] = product_href(doc['type'], doc['id']) else: ui_doc["href"] = self.env.href(doc['type'], doc['id']) ui_doc['title'] = str(doc['type'] + ": " + doc['_stored_name']).title() return ui_doc
def _process_doc(self, doc): ui_doc = dict(doc) if doc.get('product'): env = ProductEnvironment(self.env, doc['product']) product_href = ProductEnvironment.resolve_href(env, self.env) # pylint: disable=too-many-function-args ui_doc["href"] = product_href(doc['type'], doc['id']) else: ui_doc["href"] = self.req.href(doc['type'], doc['id']) if doc['content']: ui_doc['content'] = shorten_result(doc['content']) if doc['time']: ui_doc['date'] = user_time(self.req, format_datetime, doc['time']) is_free_text_view = self.view is None if is_free_text_view: participant = self.allowed_participants[doc['type']] ui_doc['title'] = participant.format_search_results(doc) return ui_doc
def render_widget(self, name, context, options): """Gather product list and render data in compact view """ data = {} req = context.req title = '' params = ('max', 'cols') max_, cols = self.bind_params(name, options, *params) if not isinstance(self.env, ProductEnvironment): for p in Product.select(self.env): if 'PRODUCT_VIEW' in req.perm(Neighborhood('product', p.prefix)): penv = ProductEnvironment(self.env, p.prefix) phref = ProductEnvironment.resolve_href(penv, self.env) for resource in ( {'type': Milestone, 'name': 'milestone', 'hrefurl': True}, {'type': Component, 'name': 'component'}, {'type': Version, 'name': 'version'}, ): setattr(p, resource['name'] + 's', self._get_product_info(p, phref, resource, max_)) p.owner_link = Query.from_string(self.env, 'status!=closed&col=id&col=summary&col=owner' '&col=status&col=priority&order=priority' '&group=product&owner=%s' % (p._data['owner'] or '', ) ).get_href(phref) p.href = phref() data.setdefault('product_list', []).append(p) title = _('Products') data['colseq'] = itertools.cycle(xrange(cols - 1, -1, -1)) if cols \ else itertools.repeat(1) return 'widget_product.html', { 'title': title, 'data': data, 'ctxtnav': [tag.a(_('More'), href=req.href('products'))], }, context
def admin_url(prefix): env = ProductEnvironment.lookup_env(self.env, prefix) href = ProductEnvironment.resolve_href(env, self.env) return href.admin()