def delete_ticket(self, t_id): """Deletes the ticket with the given ticket id""" atm = AgiloTicketModelManager(self.env) ticket = atm.get(tkt_id=t_id) try: atm.delete(ticket) except Exception, e: print exception_to_unicode(e)
def delete_all_tickets(self): """Delete all the tickets in the environment""" atm = AgiloTicketModelManager(self.env) tickets = atm.select() for t in tickets: try: atm.delete(t) except Exception, e: print exception_to_unicode(e)
def get_ticket_as_json_if_allowed(self, req): ticket_id = self.get_ticket_id(req.args) if ticket_id is None: return {} ticket = AgiloTicketModelManager(self.env).get(tkt_id=ticket_id) if not req.perm.has_permission(Action.TICKET_VIEW, ticket.resource): return {} return self.get_ticket_as_json(req, ticket.id)
def create_ticket(self, t_type, props=None): """Utility to create a ticket of the given type""" if props is None: props = {} self._ticket_counter += 1 ticket = AgiloTicketModelManager(self.env).create(t_type=t_type, save=False) ticket[Key.SUMMARY] = u'%s n.%s' % (t_type.title(), self._ticket_counter) ticket[Key.DESCRIPTION] = u'Description for ' + t_type ticket[Key.STATUS] = Status.NEW for field_name, value in props.items(): assert ticket.is_writeable_field(field_name), field_name value = self._replace_object_by_name(field_name, value) ticket[field_name] = value AgiloTicketModelManager(self.env).save(ticket) self.objects.append(ticket) return ticket
def load_ticket(self, ticket=None, t_id=None): """ Utility method to load a ticket from trac. Used to check committed changes """ assert ticket or t_id, "Supply either a ticket or and id" if ticket: t_id = ticket.id tm = AgiloTicketModelManager(self.env) tm.get_cache().invalidate(key_instance=((t_id, ), None)) t = tm.get(tkt_id=t_id) return t