incubator-bloodhound-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Martin <gary.mar...@wandisco.com>
Subject Re: svn commit: r1386610 - in /incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct: api.py web_ui.py
Date Mon, 17 Sep 2012 13:54:11 GMT
https://issues.apache.org/bloodhound/ticket/94 is a ticket about making 
Activity areas filter to show events that are specific for the level so 
that drilling down the information is limited to the scope of the object 
being viewed.

At this point we have the dashboard, products and components filtering 
in this way.

Cheers,
     Gary

On 09/17/2012 02:43 PM, gjm@apache.org wrote:
> Author: gjm
> Date: Mon Sep 17 13:43:48 2012
> New Revision: 1386610
>
> URL: http://svn.apache.org/viewvc?rev=1386610&view=rev
> Log:
> product resource manager and rendering context - towards #94 (from olemis with minor
changes)
>
> Modified:
>      incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py
>      incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py
>
> Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py
> URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py?rev=1386610&r1=1386609&r2=1386610&view=diff
> ==============================================================================
> --- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py (original)
> +++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/api.py Mon Sep 17
13:43:48 2012
> @@ -19,13 +19,16 @@
>   """Core components to support multi-product"""
>   from datetime import datetime
>   
> +from genshi.builder import tag
> +
>   from pkg_resources import resource_filename
>   from trac.core import Component, TracError, implements
>   from trac.db import Table, Column, DatabaseManager
>   from trac.env import IEnvironmentSetupParticipant
>   from trac.perm import IPermissionRequestor
> +from trac.resource import IResourceManager
>   from trac.ticket.api import ITicketFieldProvider
> -from trac.util.translation import N_
> +from trac.util.translation import _, N_
>   from trac.web.chrome import ITemplateProvider
>   
>   from multiproduct.model import Product
> @@ -38,7 +41,7 @@ class MultiProductSystem(Component):
>       """Creates the database tables and template directories"""
>       
>       implements(IEnvironmentSetupParticipant, ITemplateProvider,
> -            IPermissionRequestor, ITicketFieldProvider)
> +            IPermissionRequestor, ITicketFieldProvider, IResourceManager)
>       
>       SCHEMA = [
>           Table('bloodhound_product', key = ['prefix', 'name']) [
> @@ -94,7 +97,7 @@ class MultiProductSystem(Component):
>                   self.log.debug("creating initial db tables for %s plugin." %
>                                  PLUGIN_NAME)
>                   
> -                db_connector, _ = DatabaseManager(self.env)._get_connector()
> +                db_connector, dummy = DatabaseManager(self.env)._get_connector()
>                   for table in self.SCHEMA:
>                       for statement in db_connector.to_sql(table):
>                           db(statement)
> @@ -125,3 +128,43 @@ class MultiProductSystem(Component):
>           """Product radio fields"""
>           return []
>   
> +    # IResourceManager methods
> +
> +    def get_resource_realms(self):
> +        """Manage 'product' realm.
> +        """
> +        yield 'product'
> +
> +    def get_resource_description(self, resource, format='default', context=None,
> +                                 **kwargs):
> +        """Describe product resource.
> +        """
> +        desc = resource.id
> +        if format != 'compact':
> +            desc = _('Product %(name)s', name=resource.id)
> +        if context:
> +            return self._render_link(context, resource.id, desc)
> +        else:
> +            return desc
> +
> +    def _render_link(self, context, name, label, extra=''):
> +        """Render link to product page.
> +        """
> +        product = Product.select(self.env, where={'name' : name})
> +        if product:
> +            product = product[0]
> +            href = context.href.products(product.prefix)
> +            if 'PRODUCT_VIEW' in context.perm(product.resource):
> +                return tag.a(label, class_='product', href=href + extra)
> +        elif 'MILESTONE_CREATE' in context.perm('product', name):
> +            return tag.a(label, class_='missing product',
> +                    href=context.href('products', action='new'),
> +                    rel='nofollow')
> +        return tag.a(label, class_='missing product')
> +
> +    def resource_exists(self, resource):
> +        """Check whether product exists physically.
> +        """
> +        products = Product.select(self.env, where={'name' : resource.id})
> +        return bool(products)
> +
>
> Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py
> URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py?rev=1386610&r1=1386609&r2=1386610&view=diff
> ==============================================================================
> --- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py (original)
> +++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py Mon Sep
17 13:43:48 2012
> @@ -26,11 +26,11 @@ from genshi.builder import tag
>   from genshi.core import Attrs, QName
>   
>   from trac.core import Component, implements, TracError
> -from trac.web.chrome import (add_link, add_notice, add_warning, prevnext_nav,
> -                             Chrome, INavigationContributor)
> -from trac.resource import ResourceNotFound
> +from trac.resource import Resource, ResourceNotFound
>   from trac.util.translation import _
>   from trac.web.api import IRequestFilter, IRequestHandler, Request, HTTPNotFound
> +from trac.web.chrome import (add_link, add_notice, add_warning, prevnext_nav,
> +                             Chrome, INavigationContributor, web_context)
>   from trac.web.main import RequestDispatcher
>   
>   from multiproduct.model import Product
> @@ -150,7 +150,8 @@ class ProductModule(Component):
>           except ResourceNotFound:
>               product = Product(self.env)
>           
> -        data = {'product': product}
> +        data = {'product': product,
> +                'context': web_context(req, product.resource)}
>           
>           if req.method == 'POST':
>               if req.args.has_key('cancel'):
> @@ -172,7 +173,8 @@ class ProductModule(Component):
>               return 'product_delete.html', data, None
>           
>           if pid is None:
> -            data = {'products': products}
> +            data = {'products': products,
> +                    'context': web_context(req, Resource('products', None))}
>               return 'product_list.html', data, None
>           
>           def add_product_link(rel, product):
> @@ -203,7 +205,8 @@ class ProductModule(Component):
>           chrome = Chrome(self.env)
>           chrome.add_jquery_ui(req)
>           chrome.add_wiki_toolbars(req)
> -        data = {'product': product}
> +        data = {'product': product,
> +                'context' : web_context(req, product.resource)}
>           return 'product_edit.html', data, None
>       
>       def _do_save(self, req, product):
>
>


Mime
View raw message