Пример #1
0
 def get(self, *args):
     token, id = getQueryParametes(self, ['token', 'id'])
     user = mydb.getUserByToken(token)
     userTickets = mydb.getAllUserTickets(user["username"])
     if mydb.doesThisTicketExists(id) and mydb.changeTicketStatus(id, "Closed"):
         self.write({
             "message": "Ticket With id -%s- Closed Successfully" % id,
             "code": "200"
         })
         return
     else:
         self.write({
             "message": "No such user or ticket",
             "code": "404"
         })
         return
Пример #2
0
    def post(self, *args, **kwargs):
        token, id, status = getPostParameters(self, ['token', 'id', 'status'])
        if (not token):
            self.write({
                "message": "token is required"
            })
            return
        if (not id or not status):
            self.write({
                "message": "the ticket id and the status are required"
            })
            return

        user = mydb.getUserByToken(token)
        if not user:
            self.write({
                "message": "token is not valid"
            })
            return

        if not mydb.isThisTokenAdmin(token):
            self.write({
                "message": "token is not valid"
            })
            return

        if  mydb.doesThisTicketExists(id) and mydb.changeTicketStatus(id, status):
            self.write({
                "message": "Status Ticket With id -%s- Changed Successfully" % id,
                "code": "200"
            })
            return
        else:
            self.write({
                "message": "No such ticket or user",
                "code": "404"
            })
            return
Пример #3
0
    def post(self, *args, **kwargs):
        token, id, body = getPostParameters(self, ['token', 'id', 'body'])
        if(not token):
            self.write({
                "message": "token is required"
            })
            return
        if(not id or not body):
            self.write({
                "message": "the ticket id and the response text are required"
            })
            return

        user = mydb.getUserByToken(token)
        if not user:
            self.write({
                "message": "token is not valid"
            })
            return

        if not mydb.isThisTokenAdmin(token):
            self.write({
                "message": "token is not valid"
            })
            return

        if mydb.doesThisTicketExists(id) and mydb.saveThisResponseForThisTicket(id, body):
            self.write({
                "message": "Response to Ticket With id -%s- Sent Successfully" % id,
                "code": "200"
            })
        else:
            self.write({
                "message": "Response to Ticket With id -%s- Was not Successfully. Please get sure for ticket existence." % id,
                "code": "200"
            })