Ticket #5641: ITicketCustomFieldValues.patch
| File ITicketCustomFieldValues.patch, 2.0 KB (added by Colin Guthrie, 13 months ago) |
|---|
-
trac/ticket/api.py
132 132 ticket. Therefore, a return value of `[]` means everything is OK.""" 133 133 134 134 135 class ITicketCustomFieldValues(Interface): 136 """Allow for plugins to provide a list of possible values for custom fields.""" 137 138 def get_values(): 139 """Get a list of possible values for a custom field 140 141 Must return a list of `(value, display)` tuples, one for each custom 142 value. `display` is currently ignored (e.g. just make it `None`) 143 but is included for future compatibility. A return value of `[]` 144 will suppress the display of the custom field""" 145 146 135 147 class TicketContext(Context): 136 148 """Context used for describing Ticket resources.""" 137 149 … … 176 188 include_missing=False, 177 189 doc="""Ordered list of workflow controllers to use for ticket actions 178 190 (''since 0.11'').""") 191 custom_values = ExtensionPoint(ITicketCustomFieldValues) 179 192 180 193 restrict_owner = BoolOption('ticket', 'restrict_owner', 'false', 181 194 """Make the owner field of tickets use a drop-down menu. See … … 294 307 } 295 308 if field['type'] == 'select' or field['type'] == 'radio': 296 309 field['options'] = config.getlist(name + '.options', sep='|') 310 if len(field['options']) == 1 and field['options'][0].startswith('custom:'): 311 custom_name = field['options'][0].split(':')[1] 312 field['options'].pop() 313 for custom_value in self.custom_values: 314 if custom_value.__class__.__name__ == custom_name: 315 for value,display in custom_value.get_values(): 316 field['options'].append(value) 317 break 297 318 if '' in field['options']: 298 319 field['optional'] = True 299 320 field['options'].remove('')
