Edgewall Software

Opened 8 years ago

Closed 8 years ago

#11996 closed defect (fixed)

incorrect milestone pre-selected in change properties dropdown menu when empty

Reported by: ebouaziz@… Owned by: Ryan J Ollos
Priority: normal Milestone: 1.1.5
Component: ticket system Version: 1.1.3
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fixed: default milestone selected after ticket creation when milestone empty.

API Changes:
Internal Changes:


following #11018

Since Trac uses the null value to represent empty properties in the database, when the milestone of a ticket is empty, the milestone dropdown menu in the change properties area has the default milestone pre-selected instead of the empty one.

A visible effect is that if you simply want to add a comment on such a ticket, the milestone will be changed from empty to the default milestone, which is not empty in our case.

This does not happen on tickets that have an empty milestone represented as an empty string.

It also happens with the version property.

This happens because of the get_value_or_default() function in trac/ticket/model.py:

I believe the line:

    return value if value is not empty else self.get_default(name)

should be:

    return value if value is not empty else ''

This function is called only in trac/ticket/templates/ticket.html to fill the ticket's fields.

Attachments (0)

Change History (5)

comment:1 by Ryan J Ollos, 8 years ago

Milestone: 1.1.5
Owner: set to Ryan J Ollos
Status: newassigned

comment:2 by Ryan J Ollos, 8 years ago

I can reproduce the issue on 1.0-stable as well, I think it's not related to #11018.

Proposed fix:

  • trac/ticket/templates/ticket.html

    diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html
    index 40b97c8..3bbfc8a 100644
    a b ${ticket.description}</textarea>  
    226226                    py:if="can_modify or can_create"
    227227                    py:with="fullrow = len(row) == 1">
    228228                  <py:for each="idx, field in enumerate(row)"
    229                           py:with="value = ticket.get_value_or_default(field.name)">
     229                          py:with="value = ticket[field.name] if ticket.exists
     230                                                              else ticket.get_value_or_default(field.name)">
    230231                    <th class="col${idx + 1}" py:if="idx == 0 or not fullrow">
    231232                      <label for="field-${field.name}" py:if="field"
    232233                             py:strip="field.type == 'radio'" i18n:msg="field">${

comment:3 by ebouaziz@…, 8 years ago

yes, it's probably better this way!

comment:4 by Ryan J Ollos, 8 years ago

Release Notes: modified (diff)

Proposed changes in log:rjollos.git:t11996.

comment:5 by Ryan J Ollos, 8 years ago

Resolution: fixed
Status: assignedclosed

Committed to 1.0-stable in [13944], merged to trunk in [13945:13946]

Modify Ticket

Change Properties
Set your email in Preferences
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.