You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by gj...@apache.org on 2012/11/02 12:55:13 UTC

svn commit: r1404931 - /incubator/bloodhound/trunk/trac/trac/ticket/api.py

Author: gjm
Date: Fri Nov  2 11:55:12 2012
New Revision: 1404931

URL: http://svn.apache.org/viewvc?rev=1404931&view=rev
Log:
updating Trac to allow ticket fields to store references to resources using a different primary key than the name - #towards #110

Modified:
    incubator/bloodhound/trunk/trac/trac/ticket/api.py

Modified: incubator/bloodhound/trunk/trac/trac/ticket/api.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/trac/trac/ticket/api.py?rev=1404931&r1=1404930&r2=1404931&view=diff
==============================================================================
--- incubator/bloodhound/trunk/trac/trac/ticket/api.py (original)
+++ incubator/bloodhound/trunk/trac/trac/ticket/api.py Fri Nov  2 11:55:12 2012
@@ -165,6 +165,7 @@ class ITicketFieldProvider(Interface):
         (rank, field)
         where field is a dictionary that defines:
             * name: the field name 
+            * pk: the primary key of the field table
             * label: the label to display, preferably wrapped with N_()
             * cls: the model describing the field
         the following keys can also usefully be defined:
@@ -344,7 +345,10 @@ class TicketSystem(Component):
         for rank, field in selects:
             cls = field['cls']
             name = field['name']
-            options = [val.name for val in cls.select(self.env, db=db)]
+            pk_field = field.get('pk', 'name')
+            options = [getattr(val, pk_field)
+                       for val in cls.select(self.env, db=db)]
+
             if not options:
                 # Fields without possible values are treated as if they didn't
                 # exist