You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by rj...@apache.org on 2014/01/27 07:19:06 UTC

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

Author: rjollos
Date: Mon Jan 27 06:19:06 2014
New Revision: 1561589

URL: http://svn.apache.org/r1561589
Log:
0.8dev: Only display products in the QCT dialog for which the user has `TICKET_CREATE` permission. Refs #388.

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=1561589&r1=1561588&r2=1561589&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Mon Jan 27 06:19:06 2014
@@ -539,6 +539,7 @@ class QuickCreateTicketDialog(Component)
             if data is None:
                 data = {}
             dum_req = dummy_request(self.env)
+            dum_req.perm = req.perm
             ticket = Ticket(self.env)
             tm._populate(dum_req, ticket, False)
             all_fields = dict([f['name'], f]
@@ -547,7 +548,14 @@ class QuickCreateTicketDialog(Component)
 
             product_field = all_fields.get('product')
             if product_field:
-                if self.env.product:
+                # Filter out products for which user doesn't have TICKET_CREATE
+                product_field['options'] = \
+                    [prefix for prefix in product_field['options']
+                     if req.perm.has_permission('TICKET_CREATE',
+                                                Neighborhood('product', prefix)
+                                                    .child(None, None))]
+                if self.env.product and \
+                        self.env.product.prefix in product_field['options']:
                     product_field['value'] = self.env.product.prefix
                 product_field['options_desc'] = [
                     ProductEnvironment.lookup_env(self.env, p).product.name