|Version 8 (modified by anonymous, 5 years ago) (diff)|
Various hacks to alter Ticket form behavior
Trac in 0.11 provided us with this incredibly powerful and terrible bit of dark power -- the ability to apply Genshi Transformers to the templates before they hit the user. The power is awesome; and with this plugin I have abused that power for evil purposes.
And there are plans for more evil in the future!
Basically, the plugin adds the ability to tweak any of the Ticket fields-- be they custom or standard-- in the following ways:
- disable - The field won't be editable.
- hide - The field will simply be invisible.
- label - Rename a field... in particular one of the built-in fields.
- notice - Add a small notice below a field.
- tip - Provide a pretty java-script tooltip when the control overs over the field. (Useful, for example, to give people a reminder for the difference between 'priority' and 'severity'
- permission - Set a permission that is required to edit that specific field. This is particularly useful in an environment where you let users set severity-- so they need TICKET_CHGPROP-- but you only want certain people to be able to edit the Priority.
The plugin also lets you define arbitrary permissions, say, MASTER_OF_PRIORITIES, if you want to require someone to have such a custom permission to edit a certain field.
More evil hacks to come-- one day, I'll make it so the fields available in COMPONENT (For example) will be different depending on what Ticket Type you choose.
P.S. I am emphasizing the 'evil hackitude' of this because it seems terribly unclean and a bad idea to abuse. But it works for me! :)
If you have any issues, create a new ticket.
Installation and Configuration
You probably need to install Genshi from the trunk before this will work (>=0.5dev), at least until 0.11 comes out final.
- Download the zipped source from here.
- You can check out BlackMagicTicketTweaksPlugin using Subversion, or browse the source with Trac.
The easiest way to install the BlackMagicTicketTweaksPlugin is to simply point easy_install at the t-h.o SVN repository, a la:
Alternatively, you may download the source and go into the 0.11 directory and then run:
python setup.py install
After you have installed the BlackMagicTicketTweaksPlugin, you must enable it. You can do so in the Administration panel of Trac, or in trac.ini by adding:
[components] blackmagic.* = enabled
Any fields that you would like to tweak with this plugin must be listed in the tweaks option of the [blackmagics] section in your TracIni. This list is comma-separated and lower case. For example:
[blackmagic] tweaks = cc, priority, severity
Next you must specify all the actions that you want performed on those fields. You may have as many actions as you'd like.
The actions are specified as <field>.<action> = <value>
[blackmagic] tweaks = priority priority.permission = TRAC_ADMIN
The following actions are supported at this time:
- If True, the field will be present and its value shown but it won't be editable. By default the label will be striked out, but if you set the gray_disabled option to some value, that color will be used instead. Suggested value is something like #cccccc
- If True, the field will be completely removed and so not settable and invisible.
- The label for the field will be renamed to this value. Not terribly useful for the custom fields, but it lets you adjust the default fields names.
- Adds a small notice under the field; useful for little notes about the field.
- A comma-separated list of permissions that the user must have at least one of to edit this field. If they do not, the field will be disabled (as above). This allows per-field permissions.
- This only means something on a field with a permission action set. In this case, it determines how to handle if the user has no such permission. Valid options are either 'disable' (default) or 'hide', both treated as if the field had such an action set as above.
You may create new permissions in Trac for use above (or anywhere you'd like, really) by specifying the permission option, as in:
[blackmagic] permissions = TICKET_CHG_PRIORITY, TICKET_CHG_CC
[blackmagic] permissions = MASTER_OF_PERMISSIONS tweaks = severity, priority priority.tip = The priority is the Project-defined importance of the issue, and in general the order in which thigns will tend to be done. severity.tip = The severity is how important this issue is to the customer or you. priority.permission = MASTER_OF_PERMISSIONS
-  by rjollos on 2013-06-12 00:14:09
Refs #7185: Added additional checks for existence of variables since some parameters may not exist for all reports.
-  by rjollos on 2013-06-12 00:13:51
Fixed PEP-0008 violations, including incorrect indentation and unused imports. Moved license to COPYING file.
-  by rjollos on 2013-04-04 06:25:26
Fixes #11004, Refs #10984: Append a colon to the label in the property box too. This change should have been part of .