Ejemplo n.º 1
0
 def search_ticket(self, pattern):
     try:
         id = int(pattern)
         if Ticket.select().where(Ticket.id == id).exists():
             return True
     except ValueError:
         tickets = Ticket.select().where(
             Ticket.name.contains(pattern)).execute()
         return tickets
Ejemplo n.º 2
0
 def create_ticket(self,
                   name,
                   description,
                   image,
                   authorId,
                   productId,
                   state=0):
     Ticket.create(name=name,
                   image=image,
                   description=description,
                   state=state,
                   author_id=authorId,
                   product_id=productId)
Ejemplo n.º 3
0
    def get_commented_tickets(self, userId):
        tickets = Ticket.select() \
                     .join(Comment) \
                     .where(Comment.author_id == userId) \
                     .order_by(Comment.creation_date.desc()) \
                     .execute()

        distinctTickets = []
        distinctName = []
        for ticket in tickets:
            if not ticket.name in distinctName:
                distinctName.append(ticket.name)
                distinctTickets.append(ticket)

        return distinctTickets
Ejemplo n.º 4
0
 def get_ticket(self, ticketId):
     return Ticket.select() \
                  .where(Ticket.id == ticketId) \
                  .first()
Ejemplo n.º 5
0
 def update_ticket_state(self, ticketId, state):
     ticket = Ticket()
     ticket.id = ticketId
     ticket.state = state
     ticket.save()
Ejemplo n.º 6
0
 def get_task_tickets(self, taskId):
     return Ticket.select() \
                  .join(Task_Ticket) \
                  .where(Task_Ticket.task_id == taskId) \
                  .execute()
Ejemplo n.º 7
0
 def get_created_tickets(self, userId):
     return Ticket.select() \
                  .where(Ticket.author_id == userId) \
                  .order_by(Ticket.creation_date.desc()) \
                  .execute()
Ejemplo n.º 8
0
 def get_product_tickets(self, productId):
     return Ticket.select() \
                  .join(Product) \
                  .where(Product.id == productId) \
                  .order_by(Ticket.creation_date.desc()) \
                  .execute()
Ejemplo n.º 9
0
 def get_tickets(self):
     return Ticket.select() \
                  .execute()