You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by as...@apache.org on 2013/07/22 13:49:22 UTC

svn commit: r1505666 - /bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Author: astaric
Date: Mon Jul 22 11:49:21 2013
New Revision: 1505666

URL: http://svn.apache.org/r1505666
Log:
Create product tickets using product env.
    
Settting the product field results in sql error on postgres, as
additional product field in sql translator, resulting in an invalid
sql.

Refs #601

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=1505666&r1=1505665&r2=1505666&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Mon Jul 22 11:49:21 2013
@@ -550,11 +550,15 @@ class QuickCreateTicketDialog(Component)
 
         PS: Borrowed from XmlRpcPlugin.
         """
-        t = Ticket(self.env)
+        attrs = dict(attributes)
+        product = attrs.pop('product', '')
+        env = self._get_env(product)
+
+        t = Ticket(env)
         t['summary'] = summary
         t['description'] = description
         t['reporter'] = req.authname
-        for k, v in attributes.iteritems():
+        for k, v in attrs.iteritems():
             t[k] = v
         t['status'] = 'new'
         t['resolution'] = ''
@@ -562,12 +566,21 @@ class QuickCreateTicketDialog(Component)
 
         if notify:
             try:
-                tn = TicketNotifyEmail(self.env)
+                tn = TicketNotifyEmail(env)
                 tn.notify(t, newticket=True)
             except Exception, e:
                 self.log.exception("Failure sending notification on creation "
                                    "of ticket #%s: %s" % (t.id, e))
-        return t['product'], t.id
+        return product, t.id
+
+    def _get_env(self, product):
+        global_env = self.env.parent or self.env
+        if product:
+            env = ProductEnvironment(global_env, product)
+        else:
+            env = global_env
+        return env
+
 
 from pkg_resources import get_distribution
 application_version = get_distribution('BloodhoundTheme').version