1. Olemis Lang
  2. bloodhound-trac


g...@13f79535-47bb-0310-9956-ffa450edef68  committed 43050bf Draft

updating Trac to allow ticket fields to store references to resources using a different primary key than the name - #towards #110

  • Participants
  • Parent commits da3f7f9
  • Branches default

Comments (0)

Files changed (1)

File trac/ticket/api.py

View file
  • Ignore whitespace
         (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:
         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