| 1 | = Trac Custom Field Admin plugin = |
| 2 | |
| 3 | == Description == |
| 4 | |
| 5 | This plugin is a Web Admin page for administrating custom fields - adding, modifying and deleting them without editing the `trac.ini` file directly. |
| 6 | |
| 7 | The plugin is developed and tested for Trac 0.10.x (should work on 0.9.x). No plans yet for converting it to 0.11. |
| 8 | |
| 9 | This plugin is a cooperation between !CodeResort.com and Optaros.com, and is made freely available under a BSD license. |
| 10 | |
| 11 | Known issues: |
| 12 | * If your web server runs multiple processes, the other processes will not be able to delete custom fields - see [trac:ticket:3833] and [trac:ticket:5135] for progress on this issue. |
| 13 | |
| 14 | == Bugs/Feature Requests == |
| 15 | |
| 16 | Existing bugs and feature requests for CustomFieldAdminPlugin are |
| 17 | [report:9?COMPONENT=CustomFieldAdminPlugin here]. |
| 18 | |
| 19 | If you have any issues, create a |
| 20 | [http://trac-hacks.org/newticket?component=CustomFieldAdminPlugin&owner=osimons new ticket]. |
| 21 | |
| 22 | == Download == |
| 23 | |
| 24 | Download the zipped source from [download:customfieldadminplugin here]. |
| 25 | |
| 26 | == Source == |
| 27 | |
| 28 | You can check out CustomFieldAdminPlugin from [http://trac-hacks.org/svn/customfieldadminplugin here] using Subversion, or [source:customfieldadminplugin browse the source] with Trac. |
| 29 | |
| 30 | == Example == |
| 31 | |
| 32 | This plugin requires Web Admin plugin ([trac:wiki:WebAdmin]). |
| 33 | |
| 34 | Enable the plugin in trac.ini: |
| 35 | {{{ |
| 36 | [components] |
| 37 | customfieldadmin.* = enabled |
| 38 | }}} |
| 39 | |
| 40 | The plugin also has an API that can be called from other code if you need to create or modify custom fields. Here is an interactive session as example: |
| 41 | {{{ |
| 42 | #!python |
| 43 | from trac.env import Environment |
| 44 | from customfieldadmin.api import CustomFields |
| 45 | |
| 46 | myenv = Environment('/path/to/env') |
| 47 | mycfcomp = CustomFields(myenv) |
| 48 | |
| 49 | # Get Cusom fields (list of dicts) |
| 50 | myfields = mycfcomp.get_custom_fields(myenv) |
| 51 | for item in myfields: print item |
| 52 | |
| 53 | # Create a custom field - text box |
| 54 | mycfdict = { # a template dictionary |
| 55 | 'name': 'test01', # name of field (alphanumeric only) |
| 56 | 'type': 'text', # text|checkbox|select|radio|textarea |
| 57 | 'label': 'Test 01', # description |
| 58 | 'value': 'first test', # default value for field content |
| 59 | 'options': None, # options for select and radio types (list, leave first empty for optional) |
| 60 | 'cols': None, # number of columns for text area |
| 61 | 'rows': None, # number of rows for text area |
| 62 | 'order': 0 } # specify sort order for field, 0 for last |
| 63 | mycfcomp.update_custom_field(myenv, mycfdict, create=True) |
| 64 | |
| 65 | # Updating |
| 66 | mycfdict['type'] = 'select' |
| 67 | mycfdict['options'] = ['', 'one', 'two', 'three'] |
| 68 | mycfdict['value'] = None |
| 69 | mycfcomp.update_custom_field(myenv, mycfdict) |
| 70 | |
| 71 | # And deleting an existing custom field |
| 72 | mycfcomp.delete_custom_field(myenv, mycfdict) |
| 73 | }}} |
| 74 | |
| 75 | == Recent Changes == |
| 76 | |
| 77 | [[ChangeLog(customfieldadminplugin, 3)]] |
| 78 | |
| 79 | == Author/Contributors == |
| 80 | |
| 81 | '''Author:''' [wiki:osimons] [[BR]] |
| 82 | '''Contributors:''' |