Edgewall Software
Modify

Opened 4 years ago

Closed 4 years ago

#13284 closed task (fixed)

Skip ITicketManipulator.validate_comment when creating ticket

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

Extension point method ITicketManipulator.validate_comment is skipped when creating a ticket.

Internal Changes:

Description

comment is always None when creating a ticket, so the interface method can be skipped.

  • trac/ticket/api.py

    diff --git a/trac/ticket/api.py b/trac/ticket/api.py
    index 2dd633b6f..5ea9c96fb 100644
    a b class ITicketManipulator(Interface):  
    166166        compatibility."""
    167167
    168168    def validate_ticket(req, ticket):
    169         """Validate a ticket after it's been populated from user input.
     169        """Validate ticket properties when creating or modifying.
    170170
    171171        Must return a list of `(field, message)` tuples, one for each problem
    172172        detected. `field` can be `None` to indicate an overall problem with the
    173173        ticket. Therefore, a return value of `[]` means everything is OK."""
    174174
    175175    def validate_comment(req, comment):
    176         """Validate ticket comment after it has been edited.
     176        """Validate ticket comment when appending or editing.
    177177
    178178        Must return a list of messages, one for each problem detected.
    179179        The return value `[]` indicates no problems.
  • trac/ticket/web_ui.py

    diff --git a/trac/ticket/web_ui.py b/trac/ticket/web_ui.py
    index 53b70d454..f25b1d218 100644
    a b class TicketModule(Component):  
    13301330        # Validate custom rules.
    13311331        comment = comment or req.args.get('edited_comment')
    13321332        for manipulator in self.ticket_manipulators:
    1333             if hasattr(manipulator, 'validate_comment'):
     1333            if ticket.exists and hasattr(manipulator, 'validate_comment'):
    13341334                for message in manipulator.validate_comment(req, comment):
    13351335                    valid = False
    13361336                    add_warning(req, tag_("The ticket comment is invalid: "

Attachments (0)

Change History (2)

comment:1 by Ryan J Ollos, 4 years ago

Proposed changes in [b1b368d9c/rjollos.git].

comment:2 by Ryan J Ollos, 4 years ago

API Changes: modified (diff)
Internal Changes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to 1.4-stable in r17328, merged to trunk in r17329.

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.