Exemplo n.º 1
0
    def get(self, *args):
        token = getQueryParametes(self, ['token'])[0]
        if(not token):
            self.write({
                "message": "request in correct format"
            })
            return

        user = mydb.getUserByToken(token)

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

        userTickets = mydb.getAllUserTickets(user['username'])
        if userTickets:
            numberOfTickets = len(userTickets)
        else:
            numberOfTickets = 0
        correctFormatUserTicketsList = createUserTicketList(userTickets)

        self.write(
            collections.OrderedDict(sorted(correctFormatUserTicketsList.items()))
        )
Exemplo n.º 2
0
 def post(self, *args, **kwargs):
     token, id = getPostParameters(self, ['token', 'id'])
     user = mydb.getUserByToken(token)
     userTickets = mydb.getAllUserTickets(user["username"])
     if(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
Exemplo n.º 3
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
Exemplo n.º 4
0
    def post(self, *args, **kwargs):
        token, = getPostParameters(self, ['token'])
        if (not token):
            self.write({
                "message": "request in correct format"
            })
            return

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

        userTickets = mydb.getAllUserTickets(user["username"])
        numberOfTickets = len(userTickets)
        correctFormatUserTicketsList = createUserTicketList(userTickets)

        self.write(
            collections.OrderedDict(sorted(correctFormatUserTicketsList.items()))
        )