Beispiel #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()))
        )
Beispiel #2
0
    def post(self, *args, **kwargs):
        token, subject, body = getPostParameters(self, ['token', 'subject', 'body'])
        if (not token):
            self.write({
                "message": "token is required. please login first."
            })
            return
        if (not subject or not body):
            self.write({
                "message": "subject and body of the ticket are required."
            })
            return

        user = mydb.getUserByToken(token)

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

        ticketId = mydb.saveTicket(user['username'], subject, body)

        self.write({
            "message": "Ticket Sent Successfully",
            "id": ticketId,
            "code": "200"
        })
Beispiel #3
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
Beispiel #4
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
Beispiel #5
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
Beispiel #6
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()))
        )
Beispiel #7
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"
            })