Author: rjollos
Date: Tue Aug 27 02:22:40 2013
New Revision: 1517740
URL: http://svn.apache.org/r1517740
Log:
0.8dev: Log warning or add warning message to page when the `product` field is
missing from the ticket template's `data` dictionary. Refs #639.
Patch by Olemis.
Modified:
bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
Modified: bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL:
http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1517740&r1=1517739&r2=1517740&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Tue Aug 27 02:22:40 2013
@@ -35,7 +35,7 @@ from trac.util.presentation import to_js
from trac.util.translation import _
from trac.versioncontrol.web_ui.browser import BrowserModule
from trac.web.api import IRequestFilter, IRequestHandler, ITemplateStreamFilter
-from trac.web.chrome import (add_stylesheet, INavigationContributor,
+from trac.web.chrome import (add_stylesheet, add_warning,
INavigationContributor,
ITemplateProvider, prevnext_nav, Chrome)
from trac.wiki.admin import WikiAdmin
@@ -481,7 +481,7 @@ class QuickCreateTicketDialog(Component)
for f in tm._prepare_fields(req, ticket)
if f['type'] == 'select')
- product_field = all_fields['product']
+ product_field = all_fields.get('product')
if product_field:
if self.env.product:
product_field['value'] = self.env.product.prefix
@@ -499,6 +499,15 @@ class QuickCreateTicketDialog(Component)
ProductEnvironment.lookup_env(self.env, p).product.name
for p in product_field['options']
]
+ else:
+ msg = _("Missing ticket field '%s'.", '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],