Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Changed definition of validating option
Browse files Browse the repository at this point in the history
  • Loading branch information
rdnvndr committed Dec 18, 2015
1 parent dd7f3ec commit 9afe5e4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tracsubtickets/web_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from trac.ticket.api import ITicketManipulator
from trac.ticket.model import Ticket
from trac.resource import ResourceNotFound
from trac.config import BoolOption
from genshi.builder import tag
from genshi.filters import Transformer

Expand All @@ -45,6 +46,11 @@ class SubTicketsModule(Component):
IRequestFilter,
ITicketManipulator,
ITemplateStreamFilter)

resolve_validate = BoolOption('ticket-workflow', 'resolve.validate', True,
doc="The option of validating status of subtickets for resolving.")
reopen_validate = BoolOption('ticket-workflow', 'reopen.validate', True,
doc="The option of validating status of subtickets for reopening.")

# ITemplateProvider methods
def get_htdocs_dirs(self):
Expand Down Expand Up @@ -115,13 +121,9 @@ def get_children(self, parent_id, db=None):
return children

def validate_ticket(self, req, ticket):
validate = True
for option in self.config.options('tracsubtickets'):
if option[0] == 'validate':
validate = self.config.getbool('tracsubtickets', 'validate', True)

action = req.args.get('action')
if action == 'resolve' and validate:
if action == 'resolve' and self.resolve_validate:
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("SELECT parent, child FROM subtickets WHERE parent=%s",
Expand All @@ -131,7 +133,7 @@ def validate_ticket(self, req, ticket):
if Ticket(self.env, child)['status'] != 'closed':
yield None, _('Child ticket #%s has not been closed yet') % child

elif action == 'reopen' and validate:
elif action == 'reopen' and self.reopen_validate:
ids = set(NUMBERS_RE.findall(ticket['parents'] or ''))
for id in ids:
if Ticket(self.env, id)['status'] == 'closed':
Expand Down

0 comments on commit 9afe5e4

Please sign in to comment.