Return-Path: X-Original-To: apmail-incubator-bloodhound-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-bloodhound-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 991209E14 for ; Mon, 23 Apr 2012 12:56:02 +0000 (UTC) Received: (qmail 12343 invoked by uid 500); 23 Apr 2012 12:56:02 -0000 Delivered-To: apmail-incubator-bloodhound-commits-archive@incubator.apache.org Received: (qmail 12334 invoked by uid 500); 23 Apr 2012 12:56:02 -0000 Mailing-List: contact bloodhound-commits-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-commits@incubator.apache.org Received: (qmail 12324 invoked by uid 99); 23 Apr 2012 12:56:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Apr 2012 12:56:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Apr 2012 12:55:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 88EA923889D5; Mon, 23 Apr 2012 12:55:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1329220 - /incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Date: Mon, 23 Apr 2012 12:55:38 -0000 To: bloodhound-commits@incubator.apache.org From: gjm@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120423125538.88EA923889D5@eris.apache.org> Author: gjm Date: Mon Apr 23 12:55:38 2012 New Revision: 1329220 URL: http://svn.apache.org/viewvc?rev=1329220&view=rev Log: theme (quick ticket): determine active ticketmodule to use - disable feature when either neither or both are active - towards #23 Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1329220&r1=1329219&r2=1329220&view=diff ============================================================================== --- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original) +++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Mon Apr 23 12:55:38 2012 @@ -33,6 +33,11 @@ from themeengine.api import ThemeBase from urlparse import urlparse from wsgiref.util import setup_testing_defaults +try: + from multiproduct.ticket.web_ui import ProductTicketModule +except ImportError: + ProductTicketModule = None + def dummy_request(env, uname=None): environ = {} setup_testing_defaults(environ) @@ -101,12 +106,17 @@ class QuickCreateTicketDialog(Component) 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 = {} fakereq = dummy_request(self.env) ticket = Ticket(self.env) - tm = TicketModule(self.env) tm._populate(fakereq, ticket, False) fields = dict([f['name'], f] \ for f in tm._prepare_fields(fakereq, ticket)) @@ -125,9 +135,7 @@ class QuickCreateTicketDialog(Component) but return plain text suitable for AJAX requests. """ try: - tm = self.env[TicketModule] - if tm is None: - raise TracError('Unable to load TicketModule (disabled)?') + tm = self._get_ticket_module() req.perm.require('TICKET_CREATE') summary = req.args.pop('field_summary', '') desc = ",, ... via ''Bloodhound'' quick create ticket dialog,," @@ -140,6 +148,17 @@ class QuickCreateTicketDialog(Component) else: req.send(str(ticket_id), 'plain/text') + def _get_ticket_module(self): + ptm = None + if ProductTicketModule is not None: + ptm = self.env[ProductTicketModule] + tm = self.env[TicketModule] + if not (tm is None) ^ (ptm is None): + raise TracError('Unable to load TicketModule (disabled)?') + if tm is None: + tm = ptm + return tm + # Public API def create(self, req, summary, description, attributes = {}, notify=False): """ Create a new ticket, returning the ticket ID.