Return-Path: X-Original-To: apmail-incubator-bloodhound-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-bloodhound-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CB66ED835 for ; Mon, 17 Sep 2012 13:54:43 +0000 (UTC) Received: (qmail 89213 invoked by uid 500); 17 Sep 2012 13:54:43 -0000 Delivered-To: apmail-incubator-bloodhound-dev-archive@incubator.apache.org Received: (qmail 89184 invoked by uid 500); 17 Sep 2012 13:54:43 -0000 Mailing-List: contact bloodhound-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bloodhound-dev@incubator.apache.org Delivered-To: mailing list bloodhound-dev@incubator.apache.org Received: (qmail 89174 invoked by uid 99); 17 Sep 2012 13:54:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2012 13:54:43 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gary.martin@wandisco.com designates 74.125.83.47 as permitted sender) Received: from [74.125.83.47] (HELO mail-ee0-f47.google.com) (74.125.83.47) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2012 13:54:37 +0000 Received: by eekb57 with SMTP id b57so2970330eek.6 for ; Mon, 17 Sep 2012 06:54:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=ASdLlh+x+uLqa2lw1z0jK0iwE6LsGReJNZFosWz/gwU=; b=hRBWW3NeSTdQk1+zBrTGkPoAzfUBoiYActdKTJuSHt5rw020GuGeq7rAxDTq0ghTMV gzPmRM5knxIzRA7xplziueMazUlOBUElOQx6L3jjHTeNpIt9Nc3kwtbcz8do6BV+oLkr gQ2Q7Ty82psdyVZLD3UQ6CMuGI+OvwIl4Y9R+yGzNy1IyJnVvGQ6Y2nL6cKE1aq/L8p3 5skj3FqvCOih/uWWjwcAzwFv/kkc1076kLpU1YO2Be3rsusLxO0zKr2s3GS8x2ElZT4l ZEW4DY7mkBo17lgPF/DS6L8ii3TtyOKz5BQEZoPIEs33kAinXUjqKLf1+BwIkK4frKCa qx7Q== Received: by 10.14.223.9 with SMTP id u9mr13649480eep.10.1347890055919; Mon, 17 Sep 2012 06:54:15 -0700 (PDT) Received: from [10.2.5.143] ([77.86.30.139]) by mx.google.com with ESMTPS id k49sm27971209een.4.2012.09.17.06.54.14 (version=SSLv3 cipher=OTHER); Mon, 17 Sep 2012 06:54:15 -0700 (PDT) Message-ID: <50572B83.3000806@wandisco.com> Date: Mon, 17 Sep 2012 14:54:11 +0100 From: Gary Martin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: bloodhound-dev@incubator.apache.org Subject: Re: svn commit: r1386610 - in /incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct: api.py web_ui.py References: <20120917134349.369FF23888EA@eris.apache.org> In-Reply-To: <20120917134349.369FF23888EA@eris.apache.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnLNjIYxyVlzdBwfHRakKXDAI+hMWJAZxkuSUkV7kRj222ofpDOXaPZjGEtKrMA9WfIqJYq X-Virus-Checked: Checked by ClamAV on apache.org 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): > >