Beispiel #1
0
    def post_process_request(self, req, template, data, content_type):
        """Post process request filter.
        Removes all trac provided css if required"""

        if template is None and data is None and \
                sys.exc_info() == (None, None, None):
            return template, data, content_type

        def is_active_theme():
            is_active = False
            active_theme = ThemeEngineSystem(self.env).theme
            if active_theme is not None:
                this_theme_name = self.get_theme_names().next()
                is_active = active_theme['name'] == this_theme_name
            return is_active

        req.chrome['labels'] = self._get_whitelabelling()

        if data is not None:
            data['product_list'] = \
                ProductModule.get_product_list(self.env, req)

        links = req.chrome.get('links', {})
        # replace favicon if appropriate
        if self.env.project_icon == 'common/trac.ico':
            bh_icon = 'theme/img/bh.ico'
            new_icon = {
                'href': req.href.chrome(bh_icon),
                'type': get_mimetype(bh_icon)
            }
            if links.get('icon'):
                links.get('icon')[0].update(new_icon)
            if links.get('shortcut icon'):
                links.get('shortcut icon')[0].update(new_icon)

        is_active_theme = is_active_theme()
        if self.disable_all_trac_css and is_active_theme:
            if self.disable_all_trac_css:
                stylesheets = links.get('stylesheet', [])
                if stylesheets:
                    path = '/chrome/common/css/'
                    _iter = ([ss, ss.get('href', '')] for ss in stylesheets)
                    links['stylesheet'] = \
                        [ss for ss, href in _iter if not path in href or
                         href.rsplit('/', 1)[-1] in self.BLOODHOUND_KEEP_CSS]
            template, modifier = \
                self.BLOODHOUND_TEMPLATE_MAP.get(template, (template, None))
            if modifier is not None:
                modifier = getattr(self, modifier)
                modifier(req, template, data, content_type, is_active_theme)

        if is_active_theme and data is not None:
            data['responsive_layout'] = \
                self.env.config.getbool('bloodhound', 'responsive_layout',
                                        'true')
            data['bhrelations'] = \
                self.env.config.getbool('components', 'bhrelations.*', 'false')

        return template, data, content_type
Beispiel #2
0
    def post_process_request(self, req, template, data, content_type):
        """Post process request filter.
        Removes all trac provided css if required"""
        
        if template is None and data is None and \
                sys.exc_info() == (None, None, None):
            return template, data, content_type
        
        def is_active_theme():
            is_active = False
            active_theme = ThemeEngineSystem(self.env).theme
            if active_theme is not None:
                this_theme_name = self.get_theme_names().next()
                is_active = active_theme['name'] == this_theme_name
            return is_active

        req.chrome['labels'] = self._get_whitelabelling()

        if data is not None:
            data['product_list'] = \
                ProductModule.get_product_list(self.env, req)

        links = req.chrome.get('links', {})
        # replace favicon if appropriate
        if self.env.project_icon == 'common/trac.ico':
            bh_icon = 'theme/img/bh.ico'
            new_icon = {'href': req.href.chrome(bh_icon),
                        'type': get_mimetype(bh_icon)}
            if links.get('icon'):
                links.get('icon')[0].update(new_icon)
            if links.get('shortcut icon'):
                links.get('shortcut icon')[0].update(new_icon)
        
        is_active_theme = is_active_theme()
        if self.disable_all_trac_css and is_active_theme:
            if self.disable_all_trac_css:
                stylesheets = links.get('stylesheet', [])
                if stylesheets:
                    path = '/chrome/common/css/'
                    _iter = ([ss, ss.get('href', '')] for ss in stylesheets)
                    links['stylesheet'] = \
                        [ss for ss, href in _iter if not path in href or
                         href.rsplit('/', 1)[-1] in self.BLOODHOUND_KEEP_CSS]
            template, modifier = \
                self.BLOODHOUND_TEMPLATE_MAP.get(template, (template, None))
            if modifier is not None:
                modifier = getattr(self, modifier)
                modifier(req, template, data, content_type, is_active_theme)

        if is_active_theme and data is not None:
            data['responsive_layout'] = \
                self.env.config.getbool('bloodhound', 'responsive_layout',
                                        'true')
            data['bhrelations'] = \
                self.env.config.getbool('components', 'bhrelations.*', 'false')

        return template, data, content_type
Beispiel #3
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'
Beispiel #4
0
    def _prepare_product_breadcrumb(self):
        if not using_multiproduct(self.env):
            return
        product_search = lambda x: self.parameters.create_href(product=x)
        all_products_search = self.parameters.create_href(skip_product=True)

        global_product = [(u'', _(u'Global product'), product_search(u''))]
        products = \
            ProductModule.get_product_list(self.env, self.req, product_search)
        all_products = [(None, _(u'All products'), all_products_search)]

        search_product_list = global_product + products + all_products

        # pylint: disable=unused-variable
        for prefix, name, url in search_product_list:
            if prefix == self.active_product:
                self.data[self.DATA_ACTIVE_PRODUCT] = name
                break
        else:
            self.data[self.DATA_ACTIVE_PRODUCT] = self.active_product
        self.data[self.DATA_PRODUCT_LIST] = search_product_list
Beispiel #5
0
    def _prepare_product_breadcrumb(self):
        if not using_multiproduct(self.env):
            return
        product_search = lambda x: self.parameters.create_href(product=x)
        all_products_search = self.parameters.create_href(skip_product=True)

        global_product = [(u'', _(u'Global product'), product_search(u''))]
        products = \
            ProductModule.get_product_list(self.env, self.req, product_search)
        all_products = [(None, _(u'All products'), all_products_search)]

        search_product_list = global_product + products + all_products

        # pylint: disable=unused-variable
        for prefix, name, url in search_product_list:
            if prefix == self.active_product:
                self.data[self.DATA_ACTIVE_PRODUCT] = name
                break
        else:
            self.data[self.DATA_ACTIVE_PRODUCT] = self.active_product
        self.data[self.DATA_PRODUCT_LIST] = search_product_list
Beispiel #6
0
 def get_navigation_items(self, req):
     if 'REPORT_VIEW' in req.perm:
         href = ProductModule.get_product_path(self.env, req, 'report')
         yield ('mainnav', 'tickets', tag.a(_('View Tickets'), href=href))
Beispiel #7
0
 def get_navigation_items(self, req):
     """Overriding TicketModules New Ticket nav item"""
     if 'TICKET_CREATE' in req.perm:
         href = ProductModule.get_product_path(self.env, req, 'newticket')
         yield ('mainnav', 'newticket',
                tag.a(_("New Ticket"), href=href, accesskey=7))
Beispiel #8
0
 def get_navigation_items(self, req):
     if 'REPORT_VIEW' in req.perm:
         href = ProductModule.get_product_path(self.env, req, 'report')
         yield ('mainnav', 'tickets', tag.a(_('View Tickets'), href=href))
Beispiel #9
0
 def _assert_product_match(self, req, handler):
     self.assertIs(ProductModule(self.global_env), handler)
     self.assertEqual(self.expectedPrefix, req.args['productid'],
                      "Unexpected product prefix")
     self.assertEqual(self.expectedPathInfo, req.args['pathinfo'],
                      "Unexpected sub path")
Beispiel #10
0
 def get_navigation_items(self, req):
     if "REPORT_VIEW" in req.perm:
         href = ProductModule.get_product_path(self.env, req, "report")
         yield ("mainnav", "tickets", tag.a(_("View Tickets"), href=href))
Beispiel #11
0
 def get_navigation_items(self, req):
     """Overriding TicketModules New Ticket nav item"""
     if 'TICKET_CREATE' in req.perm:
         href = ProductModule.get_product_path(self.env, req, 'newticket')
         yield ('mainnav', 'newticket', 
                tag.a(_("New Ticket"), href=href, accesskey=7))