Hi,
Noticing that there is no standard way of custom enum field, similar
to milestone, version etc., I've created quick and dirty hack. Take
look at it, and tell me it it make sense?
The patch against version 11.1 (from Ubuntu 9.04):
--- ticket/api.py.orig 2009-08-19 14:50:19.000000000 +0200
+++ ticket/api.py 2009-08-19 15:31:34.000000000 +0200
@@ -272,6 +272,14 @@
if '' in field['options']:
field['optional'] = True
field['options'].remove('')
+ elif field['type'] == 'enum':
+ field['type'] = 'select'
+ enum_col = config.get(name + '.options')
+ from model import AbstractEnum
+ db = self.env.get_db_cnx()
+ enum_cls = type(str(enum_col),(AbstractEnum,), {})
+ enum_cls.type = enum_col
+ field['options'] = [val.name for val in
enum_cls.select(self.env, db=db)]
elif field['type'] == 'textarea':
field['width'] = config.getint(name + '.cols')
field['height'] = config.getint(name + '.rows')
The usage:
[ticket-custom]
custom_select = enum
custom_select.label = Dynamic Custom Select
custom_select.options = type_columnt_in_tbl_enum
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---