Edgewall Software
Modify

Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#11418 closed enhancement (fixed)

set_owner_to_self should use author field of form

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.3
Component: ticket system Version:
Severity: normal Keywords: workflow
Cc: Branch:
Release Notes:

The user email and name of an unauthenticated session are used to populate the new ticket owner field in the set_owner, set_owner_to_self and may_set_owner workflow operation.

API Changes:
Internal Changes:

Description

When changing a ticket the author field is populated from prefs, that author field value can be replaced by the user, and the value of the author field is used as the ticket change author. However, when accepting a ticket, the set_owner_to_self action does not use the author field when consider who the ticket should be assigned to.

The following patch has been lightly tested, but may be a starting point in aligning the behavior of the workflow with the rest of the ticket form.

  • trac/ticket/default_workflow.py

    diff --git a/trac/ticket/default_workflow.py b/trac/ticket/default_workflow.py
    index 952437a..52d1a63 100644
    a b from trac.env import IEnvironmentSetupParticipant  
    2929from trac.perm import PermissionSystem
    3030from trac.ticket.api import ITicketActionController, TicketSystem
    3131from trac.ticket.model import Resolution
     32from trac.util import get_reporter_id
    3233from trac.util.text import obfuscate_email_address
    3334from trac.util.translation import _, tag_, cleandoc_
    3435from trac.web.chrome import Chrome, add_script, add_script_data
    Read TracWorkflow for more information (don't forget to 'w  
    285286                               "%(current_owner)s to the selected user",
    286287                               current_owner=current_owner))
    287288        elif 'set_owner_to_self' in operations and \
    288                 ticket._old.get('owner', ticket['owner']) != req.authname:
     289                ticket._old.get('owner', ticket['owner']) != \
     290                        get_reporter_id(req, 'author'):
    289291            hints.append(_("The owner will be changed from %(current_owner)s "
    290292                           "to %(authname)s", current_owner=current_owner,
    291                            authname=req.authname))
     293                           authname=get_reporter_id(req, 'author')))
    292294        if 'set_resolution' in operations:
    293295            if 'set_resolution' in this_action:
    294296                resolutions = [x.strip() for x in
    Read TracWorkflow for more information (don't forget to 'wik  
    364366                    newowner = newowner[0]
    365367                updated['owner'] = newowner
    366368            elif operation == 'set_owner_to_self':
    367                 updated['owner'] = req.authname
     369                updated['owner'] = get_reporter_id(req, 'author')
    368370            elif operation == 'del_resolution':
    369371                updated['resolution'] = ''
    370372            elif operation == 'set_resolution':

Attachments (0)

Change History (10)

comment:1 by Ryan J Ollos, 11 years ago

Summary: set_owner_to_self should use author from form or prefsset_owner_to_self should use author field of form

comment:2 by Jun Omae, 11 years ago

Keywords: workflow added
Milestone: next-major-releases

comment:3 by Ryan J Ollos, 10 years ago

The *args, **kwargs in the initializer signature trunk/trac/ticket/default_workflow.py@13056:119#L101 seems to be an artifact of earlier implementation in which Component.__init__ was executed in the constructor: [5441]. I propose to remove the arguments on the trunk.

The only case I see on trac-hacks.org in which ConfigurableTicketWorkflow is instantiated in a plugin is th:AdvancedTicketWorkflowPlugin - th:browser:/advancedticketworkflowplugin/0.12/advancedworkflow/controller.py@9962:35#L22. The proposed change would not affect th:AdvancedWorkflowPlugin.

Last edited 10 years ago by Ryan J Ollos (previous) (diff)

comment:4 by Ryan J Ollos, 10 years ago

Milestone: next-major-releases1.1.3

comment:5 by Ryan J Ollos, 10 years ago

Owner: set to Ryan J Ollos
Status: newassigned

in reply to:  3 comment:6 by Ryan J Ollos, 10 years ago

Replying to rjollos:

The *args, **kwargs in the initializer signature trunk/trac/ticket/default_workflow.py@13056:119#L101 seems to be an artifact of earlier implementation in which Component.__init__ was executed in the constructor: [5441]. I propose to remove the arguments on the trunk.

Removed in [13172].

comment:7 by Ryan J Ollos, 10 years ago

Milestone: 1.1.31.0.3

One additional issue can be fixed in this ticket: when [ticket] restrict_owner = false and an unauthenticated user with name and email set for the session, the name and email should be used to populate the input in the set_owner operation, rather than anonymous.

comment:8 by Ryan J Ollos, 10 years ago

Release Notes: modified (diff)

Committed to 1.0-stable in [13215:13216], merged to trunk in [13217:13219].

In log:rjollos.git:t11418 I tried adding some unit testing, but they seemed rather klunky and contrived. Testing with functional tests continues to prove challenging because of the shared state of the environment between tests. The ideal fix could be a new functional test framework that makes the tests easier to write and allows tests to be written so that they don't share state (though the latter could possibly be done independent of the former).

Last edited 10 years ago by Ryan J Ollos (previous) (diff)

comment:9 by Ryan J Ollos, 10 years ago

Resolution: fixed
Status: assignedclosed

comment:10 by Ryan J Ollos, 10 years ago

Stupid error from [13218] was corrected in [13313]. I should pay better attention and use the debugger rather than being lazy with print statements.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.