Skip to content

Instantly share code, notes, and snippets.

@ivanelson
Last active January 1, 2016 01:39
Show Gist options
  • Save ivanelson/8074704 to your computer and use it in GitHub Desktop.
Save ivanelson/8074704 to your computer and use it in GitHub Desktop.
Just close the ticket(Trac), if you insert a comment. http://trac.edgewall.org/
#-*- encoding: utf-8 -*-
from trac.core import Component, implements
from trac.ticket.api import ITicketManipulator, ITicketChangeListener
from trac.ticket.model import Ticket
class ValidComment(Component):
implements(ITicketManipulator, ITicketChangeListener)
def prepare_ticket(self, req, ticket, fields, actions):
pass
def validate_ticket(self, req, ticket):
action = req.args.get('action')
comment = ticket._old.get('comment', ticket['comment'])
self.log.info('ValidComment Action in validate_ticket: %s' % action)
self.log.info('ValidComment Comment in validate_ticket: %s' % comment)
if action in ('resolve', 'reopen'):
if not comment:
return [(None, "Before closing the Ticket #%s, Enter a comment." % ticket.id)]
return []
def ticket_created(self, ticket):
pass
def ticket_changed(self, ticket, comment, author, old_values):
pass
@ivanelson
Copy link
Author

Hasienda,

Using the 'validate_ticket' method I need 02 actions. The first action is to write the comment and the second is closing the ticket.

How do I check if the user typed the comment in the 'form' and is also closing the ticket?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment