Exemplo n.º 1
0
 def _modify_search_data(self, req, template, data, content_type, is_active):
     """Insert breadcumbs and context navigation items in search web UI
     """
     if is_active:
         # Insert query string in search box (see bloodhound_theme.html)
         req.search_query = data.get('query')
         # Context nav
         prevnext_nav(req, _('Previous'), _('Next'))
     # Breadcrumbs nav
     data['resourcepath_template'] = 'bh_path_search.html'
Exemplo n.º 2
0
 def product_media_data(icons, product):
     return dict(href=product.href(),
                 thumb=icons.get(product.prefix, no_thumbnail),
                 title=product.name,
                 description=format_to_html(self.env,
                                            product_ctx(product),
                                            product.description),
                 links={'extras': (([{'href': req.href.products(
                                         product.prefix, action='edit'),
                                      'title': _('Edit product %(prefix)s',
                                                 prefix=product.prefix),
                                      'icon': tag.i(class_='icon-edit'),
                                      'label': _('Edit')},]
                                    if 'PRODUCT_MODIFY' in req.perm
                                    else []) +
                                   [{'href': product.href(),
                                     'title': _('Home page'),
                                     'icon': tag.i(class_='icon-home'),
                                     'label': _('Home')},
                                    {'href': product.href.dashboard(),
                                     'title': _('Tickets dashboard'),
                                     'icon': tag.i(class_='icon-tasks'),
                                     'label': _('Tickets')},
                                    {'href': product.href.wiki(),
                                     'title': _('Wiki'),
                                     'icon': tag.i(class_='icon-book'),
                                     'label': _('Wiki')}]),
                        'main': {'href': product.href(),
                                 'title': None,
                                 'icon': tag.i(class_='icon-chevron-right'),
                                 'label': _('Browse')}})
Exemplo n.º 3
0
 def get_navigation_items(self, req):
     if 'BROWSER_VIEW' in req.perm and 'VERSIONCONTROL_ADMIN' in req.perm:
         bm = self.env[BrowserModule]
         if bm and not list(bm.get_navigation_items(req)):
             yield ('mainnav', 'browser',
                    tag.a(_('Source'),
                          href=req.href.wiki('TracRepositoryAdmin')))
Exemplo n.º 4
0
    def post_process_request(self, req, template, data, content_type):
        """Append necessary ticket data
        """
        try:
            tm = self._get_ticket_module()
        except TracError:
            # no ticket module so no create ticket button
            return template, data, content_type

        if (template, data, content_type) != (None,) * 3:  # TODO: Check !
            if data is None:
                data = {}
            dum_req = dummy_request(self.env)
            dum_req.perm = req.perm
            ticket = Ticket(self.env)
            tm._populate(dum_req, ticket, False)
            all_fields = dict([f['name'], f]
                              for f in tm._prepare_fields(dum_req, ticket)
                              if f['type'] == 'select')

            product_field = all_fields.get('product')
            if product_field:
                # When at product scope, set the default selection to the
                # product at current scope. When at global scope the default
                # selection is determined by [ticket] default_product
                if self.env.product and \
                        self.env.product.prefix in product_field['options']:
                    product_field['value'] = self.env.product.prefix
                # Transform the options field to dictionary of product
                # attributes and filter out products for which user doesn't
                #  have TICKET_CREATE permission
                product_field['options'] = [
                    dict(value=p,
                         new_ticket_url=dum_req.href.products(p, 'newticket'),
                         description=ProductEnvironment.lookup_env(self.env, p)
                                                       .product.name
                    )
                for p in product_field['options']
                    if req.perm.has_permission('TICKET_CREATE',
                                               Neighborhood('product', p)
                                               .child(None, None))]
            else:
                msg = _("Missing ticket field '%(field)s'.", field='product')
                if ProductTicketModule is not None and \
                        self.env[ProductTicketModule] is not None:
                    # Display warning alert to users
                    add_warning(req, msg)
                else:
                    # Include message in logs since this might be a failure
                    self.log.warning(msg)
            data['qct'] = {
                'fields': [all_fields[k] for k in self.qct_fields
                           if k in all_fields],
                'hidden_fields': [all_fields[k] for k in all_fields.keys()
                                  if k not in self.qct_fields] }
        return template, data, content_type
Exemplo n.º 5
0
    def _modify_admin_breadcrumb(self, req, template, data, content_type, is_active):
        # override 'normal' product list with the admin one

        def admin_url(prefix):
            env = ProductEnvironment.lookup_env(self.env, prefix)
            href = ProductEnvironment.resolve_href(env, self.env)
            return href.admin()

        global_settings = (None, _('(Global settings)'), admin_url(None))

        data['admin_product_list'] = [global_settings] + \
            ProductModule.get_product_list(self.env, req, admin_url)

        if isinstance(req.perm.env, ProductEnvironment):
            product = req.perm.env.product
            data['admin_current_product'] = \
                (product.prefix, product.name,
                 req.href.products(product.prefix, 'admin'))
        else:
            data['admin_current_product'] = global_settings
        data['resourcepath_template'] = 'bh_path_general.html'