Edgewall Software
Modify

Opened 8 years ago

Closed 8 years ago

#12400 closed defect (fixed)

Custom field "milestone" is not appeared with the field is defined and defined milestones are removed

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.0.11
Component: ticket system Version: 1.0.10
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fix missing milestone field in ticket form when the field is custom field and no defined milestones.

API Changes:
Internal Changes:

Description (last modified by Jun Omae)

Custom field is allow to use the same name of ticket field when no defined enums/components/milestones/versions. Actually, priority, version, component, resolution, severity and type fields is appeared in ticket box and form.

However, milestone field is not appeared in ticket form. The milestone is appeared in ticket view.

[ticket-custom]
priority = text
priority.format = plain
priority.label = (priority)
priority.options =
priority.order = 1
priority.value =
milestone = text
milestone.format = plain
milestone.label = (milestone)
milestone.options =
milestone.order = 2
milestone.value =
version = text
version.format = plain
version.label = (version)
version.options =
version.order = 3
version.value =
component = text
component.format = plain
component.label = (component)
component.options =
component.order = 4
component.value =
resolution = text
resolution.format = plain
resolution.label = (resolution)
resolution.options =
resolution.order = 5
resolution.value =
severity = text
severity.format = plain
severity.label = (severity)
severity.options =
severity.order = 6
severity.value =
type = text
type.format = plain
type.label = (type)
type.options =
type.order = 7
type.value =

Attachments (2)

ticket-box.png (10.3 KB ) - added by Jun Omae 8 years ago.
ticket-form.png (15.0 KB ) - added by Jun Omae 8 years ago.

Download all attachments as: .zip

Change History (8)

by Jun Omae, 8 years ago

Attachment: ticket-box.png added

by Jun Omae, 8 years ago

Attachment: ticket-form.png added

comment:1 by Jun Omae, 8 years ago

Description: modified (diff)

comment:2 by Jun Omae, 8 years ago

Description: modified (diff)

comment:3 by Jun Omae, 8 years ago

Query system crashes in this case.

2016-03-14 14:37:17,211 Trac[main] ERROR: Internal Server Error: <RequestWithSession "GET '/query'">, referrer None
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 554, in _dispatch_request
    dispatcher.dispatch(req)
  File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 247, in dispatch
    resp = chosen_handler.process_request(req)
  File "/home/jun66j5/src/tracdev/git/trac/ticket/query.py", line 1004, in process_request
    return self.display_html(req, query)
  File "/home/jun66j5/src/tracdev/git/trac/ticket/query.py", line 1121, in display_html
    data = query.template_data(context, tickets, orig_list, orig_time, req)
  File "/home/jun66j5/src/tracdev/git/trac/ticket/query.py", line 768, in template_data
    for opt in field['options']]
KeyError: 'options'

comment:4 by Jun Omae, 8 years ago

Milestone: next-stable-1.0.x1.0.11
Owner: set to Jun Omae
Status: newassigned

The following would fix missing milestone as custom field in ticket form. That issue in comment:3 would be fixed in #12399.

  • trac/ticket/tests/web_ui.py

    diff --git a/trac/ticket/tests/web_ui.py b/trac/ticket/tests/web_ui.py
    index ace7a545f..5c98ff435 100644
    a b import unittest  
    1616from trac.core import TracError
    1717from trac.resource import ResourceNotFound
    1818from trac.test import EnvironmentStub, Mock, MockPerm, locale_en
     19from trac.ticket.api import TicketSystem
    1920from trac.ticket.model import Ticket
    2021from trac.ticket.web_ui import TicketModule
    2122from trac.util.datefmt import utc
    class TicketModuleTestCase(unittest.TestCase):  
    110111        self.assertRaises(ResourceNotFound,
    111112                          self.ticket_module.process_request, req)
    112113
     114    def test_newticket_with_milestone_as_custom_field(self):
     115        self.env.config.set('ticket-custom', 'milestone', 'text')
     116        self.env.db_transaction("DELETE FROM milestone")
     117        tktsys = TicketSystem(self.env)
     118        tktsys.reset_ticket_fields()
     119        del tktsys.custom_fields
     120
     121        req = self._create_request(path_info='/newticket')
     122        self.assertEqual(True, self.ticket_module.match_request(req))
     123        resp = self.ticket_module.process_request(req)
     124        for field in resp[1]['fields']:
     125            if field['name'] == 'milestone':
     126                self.assertTrue(field['custom'])
     127                self.assertFalse(field['options'])
     128                self.assertFalse(field.get('optgroups'))
     129                break
     130        else:
     131            self.fail('Missing milestone in fields')
     132
    113133
    114134def suite():
    115135    suite = unittest.TestSuite()
  • trac/ticket/web_ui.py

    diff --git a/trac/ticket/web_ui.py b/trac/ticket/web_ui.py
    index 5c267d9e3..f047a228b 100644
    a b class TicketModule(Component):  
    14961496                    if 'TICKET_MODIFY' in req.perm(ticket.resource):
    14971497                        field['skip'] = False
    14981498                        owner_field = field
    1499             elif name == 'milestone':
     1499            elif name == 'milestone' and not field.get('custom'):
    15001500                milestones = [Milestone(self.env, opt)
    15011501                              for opt in field['options']]
    15021502                milestones = [m for m in milestones
Last edited 8 years ago by Jun Omae (previous) (diff)

comment:5 by Jun Omae, 8 years ago

Proposed changes in log:jomae.git@t12400, added unit tests for other fields.

comment:6 by Jun Omae, 8 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Comiitted in [14633] and merged to trunk in [14634].

Modify Ticket

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