#13237 closed enhancement (fixed)
[PATCH] Operations to 'set field to self' and 'clear field(s)' requested
Reported by: | Jon Ashley | Owned by: | Jon Ashley |
---|---|---|---|
Priority: | normal | Component: | AdvancedTicketWorkflowPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description
In my local setup, I use this plugin to automatically set fields called 'evaluator', 'approver', 'implementer' and 'reviewer' to the name of the current user when the user transitions the ticket into the states 'evaluated', 'approved', 'implemented' and 'reviewed' respectively. I then use the KeepInterfaceSimplePlugin to enforce rules that prevent the user changing these fields manually and that prevent the evaluator and approver being the same user, or the implementer and reviewer being the same user.
I also use this plugin to clear the 'evaluator', 'approver', 'implementer' and 'reviewer' fields when the ticket is rolled back to an earlier state.
To do that, I have applied the attached patch which adds the operations set_field_to_self
and set_fields_to_blank
.
Attachments (1)
Change History (11)
Changed 7 years ago by
Attachment: | controller.py.patch added |
---|
comment:1 Changed 7 years ago by
Owner: | set to Jon Ashley |
---|---|
Status: | new → assigned |
comment:3 follow-up: 4 Changed 7 years ago by
I think the following in the patch should use named arguments for gettext.
hint = _("The '%s' field will be set to '%s'." % ( self._field_name(action, ticket), req.authname ))
hint = _("The '%(field)s' field will be set to '%(username)s'.", field=self._field_name(action, ticket), username=req.authname)
The following can not be translated to non-English.
hint = _("The %s%s%s field%s will be cleared." % ( ', '.join(fields[:-1]), len(fields) > 1 and ' and ' or '', fields[-1], len(fields) > 1 and 's' or '' ))
comment:4 Changed 7 years ago by
Replying to Jun Omae:
The following can not be translated to non-English.
hint = _("The %s%s%s field%s will be cleared." % ( ', '.join(fields[:-1]), len(fields) > 1 and ' and ' or '', fields[-1], len(fields) > 1 and 's' or '' ))
hint = ngettext("The %(fields)s field will be cleared.", "The %(fields)s fields will be cleared.", len(fields), fields=', '.join(fields))
Another thing: I think TicketWorkflowOpFieldsBlank._field_names
could use config.getlist()
rather than .split(',')
.
def _field_names(self, action, ticket): """Determines the fields to set to blank """ - fields_string = self.config.get('ticket-workflow', - action + '.' + self._op_name).strip() - return [x.strip() for x in fields_string.split(',')] + return self.config.getlist('ticket-workflow', + action + '.' + self._op_name)
comment:6 Changed 7 years ago by
Sorry for the late comment. For clarity, I would have named the operations set_field_to_author
and clear_fields
. The term "author" is used throughout Trac to refer to the user making the change.
comment:9 Changed 7 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Patch to add new operations as described