incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1301117 - in /incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket: __init__.py api.py
Date Thu, 15 Mar 2012 17:47:09 GMT
Author: gjm
Date: Thu Mar 15 17:47:09 2012
New Revision: 1301117

URL: http://svn.apache.org/viewvc?rev=1301117&view=rev
Log:
stops attempting to override a large part of the default TicketSystem in favour of using the
new ITicketFieldProvider interface

Modified:
    incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py
    incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/api.py

Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py?rev=1301117&r1=1301116&r2=1301117&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py (original)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/__init__.py Thu
Mar 15 17:47:09 2012
@@ -18,4 +18,4 @@
 
 """multiproduct ticket related functionality and overrides"""
 from web_ui import ProductTicketModule
-from api import ProductTicketSystem
+from api import ProductTicketFields

Modified: incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/api.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/api.py?rev=1301117&r1=1301116&r2=1301117&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/api.py (original)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/api.py Thu Mar
15 17:47:09 2012
@@ -16,92 +16,24 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-"""Multiproduct support - changes to the ticket api"""
-import re
-from trac.ticket.api import TicketSystem
+"""Multiproduct changes to the ticket api"""
+from trac.core import Component, implements
+from trac.ticket.api import ITicketFieldProvider
 
-from trac.cache import cached
 from trac.util.translation import N_
 
-from trac.ticket import model
 from multiproduct.model import Product
 
-class ProductTicketSystem(TicketSystem):
-    """Multiproduct Overrides for the TicketSystem component"""
+class ProductTicketFields(Component):
+    """Fields added to the ticket system for product support"""
     
-    @cached
-    def fields(self, db):
-        """Return the list of fields available for tickets."""
-        
-        fields = []
-        
-        # Basic text fields
-        fields.append({'name': 'summary', 'type': 'text',
-                       'label': N_('Summary')})
-        fields.append({'name': 'reporter', 'type': 'text',
-                       'label': N_('Reporter')})
-        
-        # Owner field, by default text but can be changed dynamically 
-        # into a drop-down depending on configuration (restrict_owner=true)
-        field = {'name': 'owner', 'label': N_('Owner')}
-        field['type'] = 'text'
-        fields.append(field)
-        
-        # Description
-        fields.append({'name': 'description', 'type': 'textarea',
-                       'label': N_('Description')})
-        
-        # Default select and radio fields
-        selects = [('type', N_('Type'), model.Type),
-                   ('status', N_('Status'), model.Status),
-                   ('priority', N_('Priority'), model.Priority),
-                   ('product', N_('Product'), Product),
-                   ('milestone', N_('Milestone'), model.Milestone),
-                   ('component', N_('Component'), model.Component),
-                   ('version', N_('Version'), model.Version),
-                   ('severity', N_('Severity'), model.Severity),
-                   ('resolution', N_('Resolution'), model.Resolution)]
-        for name, label, cls in selects:
-            options = [val.name for val in cls.select(self.env, db=db)]
-            if not options:
-                # Fields without possible values are treated as if they didn't
-                # exist
-                continue
-            field = {'name': name, 'type': 'select', 'label': label,
-                     'value': getattr(self, 'default_' + name, ''),
-                     'options': options}
-            if name in ('status', 'resolution'):
-                field['type'] = 'radio'
-                field['optional'] = True
-            elif name in ('product', 'milestone', 'version'):
-                field['optional'] = True
-            fields.append(field)
-        
-        # Advanced text fields
-        fields.append({'name': 'keywords', 'type': 'text',
-                       'label': N_('Keywords')})
-        fields.append({'name': 'cc', 'type': 'text', 'label': N_('Cc')})
-        
-        # Date/time fields
-        fields.append({'name': 'time', 'type': 'time',
-                       'label': N_('Created')})
-        fields.append({'name': 'changetime', 'type': 'time',
-                       'label': N_('Modified')})
-        
-        for field in self.get_custom_fields():
-            if field['name'] in [f['name'] for f in fields]:
-                self.log.warning('Duplicate field name "%s" (ignoring)',
-                                 field['name'])
-                continue
-            if field['name'] in self.reserved_field_names:
-                self.log.warning('Field name "%s" is a reserved name '
-                                 '(ignoring)', field['name'])
-                continue
-            if not re.match('^[a-zA-Z][a-zA-Z0-9_]+$', field['name']):
-                self.log.warning('Invalid name for custom field: "%s" '
-                                 '(ignoring)', field['name'])
-                continue
-            field['custom'] = True
-            fields.append(field)
-        
-        return fields
+    implements(ITicketFieldProvider)
+    
+    def get_select_fields(self):
+        """Product select fields"""
+        return [(35, {'name': 'product', 'label': N_('Product'), 
+                      'cls': Product, 'optional': True})]
+    
+    def get_radio_fields(self):
+        """Product radio fields"""
+        return []



Mime
View raw message