Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

Last modified 10 years ago

#8716 closed enhancement (fixed)

Ticket Options like default_milestone should be in the TicketSystem not the TicketModule

Reported by: Felix Schwarz <felix.schwarz@…> Owned by: Christian Boos
Priority: low Milestone: 0.12
Component: ticket system Version: 0.12dev
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

These don't have anything to do with the request or the web page. Also you can see that you need these options in the TicketSystem so that the information where/how the settings are stored in the configuration is currently duplicated.

Attachments (2)

8716_move_ticket_options_to_ticketsystem (5.8 KB ) - added by Felix Schwarz <felix.schwarz@…> 15 years ago.
8716_move_ticket_options_to_ticketsystem.patch (6.8 KB ) - added by Christian Boos 15 years ago.
Move default_... field value Options from TicketModule to TicketSystem. (patch on trunk, r8787)

Download all attachments as: .zip

Change History (13)

by Felix Schwarz <felix.schwarz@…>, 15 years ago

comment:1 by Christian Boos, 15 years ago

I'm fine with the move of options from TicketModule to TicketSystem.

However, I think both the config API and the access through descriptors have their use, one should pick whichever makes for the most readable code.

So for example:

  • trac/ticket/default_workflow.py

    diff -r 3948001eb770 trac/ticket/default_workflow.py
    a b  
    287287                               name=resolutions[0]))
    288288            else:
    289289                id = 'action_%s_resolve_resolution' % action
    290                 selected_option = req.args.get(id,
    291                         self.config.get('ticket', 'default_resolution'))
     290                selected_option = req.args.get(id, 
     291                        TicketSystem(self.env).default_resolution)
    292292                control.append(tag(['as ', tag.select(
    293293                    [tag.option(x, selected=(x == selected_option or None))
    294294                     for x in resolutions],

is fine, but:

  • trac/ticket/model.py

    diff -r 3948001eb770 trac/ticket/model.py
    a b  
    7575                # Ignore for new - only change through workflow
    7676                pass
    7777            elif not field.get('custom'):
    78                 default = self.env.config.get('ticket',
    79                                               'default_' + field['name'])
     78                default = getattr(TicketSystem(self.env), 'default_' + field['name'], None)
    8079            else:
    8180                default = field.get('value')
    8281                options = field.get('options')

makes it actually harder to read, I think.

in reply to:  1 ; comment:2 by Remy Blank, 15 years ago

Replying to cboos:

I'm fine with the move of options from TicketModule to TicketSystem.

Won't this unnecessarily break plugins that expect those options in TicketModule? Shouldn't we at least have "forwarders" in TicketModule and deprecate their use?

in reply to:  2 ; comment:3 by Felix Schwarz <felix.schwarz@…>, 15 years ago

Replying to rblank:

Won't this unnecessarily break plugins that expect those options in TicketModule? Shouldn't we at least have "forwarders" in TicketModule and deprecate their use?

So the idea would be to add properties which forward to the TicketSystem + DeprecationWarning?

in reply to:  3 comment:4 by Remy Blank, 15 years ago

Replying to Felix Schwarz <felix.schwarz@…>:

So the idea would be to add properties which forward to the TicketSystem + DeprecationWarning?

I'd say yes for the properties, but DeprecationWarnings are ugly. I would just add a big fat comment above the properties warning that they will be removed in 0.13.

by Christian Boos, 15 years ago

Move default_... field value Options from TicketModule to TicketSystem. (patch on trunk, r8787)

comment:5 by Christian Boos, 15 years ago

Owner: set to Christian Boos

New patch 8716_move_ticket_options_to_ticketsystem.patch added, please review.

comment:6 by Remy Blank, 15 years ago

Looks good, one minor nitpick: I would use a single _warnings attribute with a set() of the option names where the warning has been shown, instead of using separate _warn_* attributes and getattr() magic.

comment:7 by Christian Boos, 15 years ago

Resolution: fixed
Status: newclosed

Patch applied, with the above suggestion taken into account, in [8792].

Thank you Felix for the initial patch.

comment:8 by Christian Boos, 15 years ago

Ah yes, and as discussed in comment:1, use config.get when it's more elegant than accessing the Option directly (r8793).

in reply to:  7 ; comment:9 by Remy Blank, 15 years ago

Replying to cboos:

Patch applied, with the above suggestion taken into account, in [8792].

You could even put name directly into the set(), instead of "_warn_" + name (i.e. warn_flag is obsolete) :-)

in reply to:  9 comment:10 by Christian Boos, 15 years ago

Replying to rblank:

You could even put name directly into the set(),

Done in [8800], thanks!

comment:11 by Ryan J Ollos, 10 years ago

The deprecated accessor in the TicketModule was removed in [12962] (comment:18:ticket:11494).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.