def validate_ticket(self, req, ticket): action = req.args.get('action') if action in self.opt_skip_validation: return if action == 'resolve': for parent, child in self.env.db_query( """ SELECT parent, child FROM subtickets WHERE parent=%s """, (ticket.id, )): if Ticket(self.env, child)['status'] != 'closed': yield None, _("""Cannot close/resolve because child ticket #%(child)s is still open""", child=child) elif action == 'reopen': ids = set(NUMBERS_RE.findall(ticket['parents'] or '')) for id in ids: if Ticket(self.env, id)['status'] == 'closed': msg = _( "Cannot reopen because parent ticket #%(id)s " "is closed", id=id) yield None, msg
def post_process_request(self, req, template, data, content_type): path = req.path_info if path.startswith('/ticket/') or path.startswith('/newticket'): # get parents data ticket = data['ticket'] parents = ticket['parents'] or '' ids = set(NUMBERS_RE.findall(parents)) if len(parents) > 0: self._append_parent_links(req, data, ids) children = self.get_children(ticket.id) if children: data['subtickets'] = children return template, data, content_type
def validate_ticket(self, req, ticket): action = req.args.get('action') if action == 'resolve': db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("SELECT parent, child FROM subtickets WHERE parent=%s", [str(ticket.id)] ) for parent, child in cursor: if Ticket(self.env, child)['status'] != 'closed': yield None, _('Child ticket #%s has not been closed yet') % child elif action == 'reopen': ids = set(NUMBERS_RE.findall(ticket['parents'] or '')) for id in ids: if Ticket(self.env, id)['status'] == 'closed': yield None, _('Parent ticket #%s is closed') % id
def post_process_request(self, req, template, data, content_type): path = req.path_info if path.startswith('/ticket/') or path.startswith('/newticket'): # get parent ticket's data if data and 'ticket' in data: ticket = data['ticket'] parents = ticket['parents'] or '' ids = set(NUMBERS_RE.findall(parents)) if len(parents) > 0: self._append_parent_links(req, data, ids) children = self.get_children(ticket.id) if children: data['subtickets'] = children return template, data, content_type
def validate_ticket(self, req, ticket): action = req.args.get('action') if action == 'resolve': db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute( "SELECT parent, child FROM subtickets WHERE parent=%s", (ticket.id, )) for parent, child in cursor: if Ticket(self.env, child)['status'] != 'closed': yield None, _( 'Child ticket #%s has not been closed yet') % child elif action == 'reopen': ids = set(NUMBERS_RE.findall(ticket['parents'] or '')) for id in ids: if Ticket(self.env, id)['status'] == 'closed': yield None, _('Parent ticket #%s is closed') % id
def post_process_request(self, req, template, data, content_type): path = req.path_info if path.startswith('/ticket/') or path.startswith('/newticket'): # get parent ticket's data if data and 'ticket' in data: ticket = data['ticket'] parents = ticket['parents'] or '' ids = set(NUMBERS_RE.findall(parents)) if len(parents) > 0: self._append_parent_links(req, data, ids) children = self.get_children(ticket.id) if children: data['subtickets'] = children elif path.startswith('/admin/ticket/type') \ and data \ and set(['add', 'name']).issubset(data.keys()) \ and data['add'] == 'Add': self._add_per_ticket_type_option(data['name']) return template, data, content_type
def check_subtickets(db): cursor = db.cursor() cfield = {} cursor.execute( "SELECT ticket, value FROM ticket_custom WHERE name='parents'") for row in cursor: id = row[0] parents = [int(x) for x in NUMBERS_RE.findall(row[1])] cfield[id] = parents subtickets = {} cursor.execute("SELECT parent, child FROM subtickets") for row in cursor: parent = int(row[0]) child = int(row[1]) if child in subtickets: subtickets[child] += [parent] else: subtickets[child] = [parent] for id in set(cfield.keys() + subtickets.keys()): result = False if id in cfield and id in subtickets: cfield_values = set(cfield[id]) subtickets_values = set(subtickets[id]) if cfield_values == subtickets_values: result = True elif id not in subtickets: if not cfield.get(id): result = True if not result: print "Mismatch in ticket #%i" % id print " custom field :", cfield.get(id, '--') print " subtickets :", subtickets.get(id, '--')
def check_subtickets(env): db = env.get_db_cnx() cursor = db.cursor() cfield = {} cursor.execute("SELECT ticket, value FROM ticket_custom WHERE name='parents'") for row in cursor: id = row[0] parents = [int(x) for x in NUMBERS_RE.findall(row[1])] cfield[id] = parents subtickets = {} cursor.execute("SELECT parent, child FROM subtickets") for row in cursor: parent = int(row[0]) child = int(row[1]) if child in subtickets: subtickets[child] += [parent] else: subtickets[child] = [parent] for id in set(cfield.keys() + subtickets.keys()): result = False if id in cfield and id in subtickets: cfield_values = set(cfield[id]) subtickets_values = set(subtickets[id]) if cfield_values == subtickets_values: result = True elif id not in subtickets: if not cfield.get(id): result = True if not result: print "Mismatch in ticket #%i" % id print " custom field :", cfield.get(id, '--') print " subtickets :", subtickets.get(id, '--')