Ejemplo n.º 1
0
    def test_editAccount(self):
        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        userdata2 = USER.objects.get(username="******")
        user2 = User.User(userdata2.permission, userdata2.username,
                          userdata2.password, userdata2.id, userdata2.email,
                          userdata2.firstName, userdata2.lastName,
                          userdata2.contactPhone, userdata2.officePhone,
                          userdata2.extension)
        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)

        self.assertTrue(user.permission[1] == 1)
        self.assertTrue(user2.permission[1] == 2)
        self.assertTrue((user3.permission[1] != 1 & user2.permission == 2),
                        "Not Authorized To Use This Command")

        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        self.assertEqual(Terminal.editAccount(user.databaseID),
                         "What Would You Like To Edit?")
        self.assertEqual(Terminal.editAccount('231231'), "User Not Found")
Ejemplo n.º 2
0
 def post(self, request):
     response = Terminal.editAccount(
         request.session['editID'], request.POST['Permission'],
         request.POST['UserName'], request.POST['Password'],
         request.POST['Email'], request.POST['FirstName'],
         request.POST['LastName'], request.POST['ContactPhone'],
         request.POST['OfficePhone'], request.POST['Extension'])
     if response == "User account updated":
         return render(request, ['http://127.0.0.1:8000/home'])
     if response == "User does not exist":
         return render(request, ['shell/editAccountError.html'])
     else:
         return render(request, ['shell/editAccountError.html'])
Ejemplo n.º 3
0
 def post(self, request):
     terminalInstance = Terminal()
     editid = request.session['editID']
     user = USER.objects.get(id=editid)
     terminalInstance.login(user.username, user.password)
     response, success = terminalInstance.editAccount(
         editid, request.POST['Permission'], request.POST['UserName'],
         request.POST['Password'], request.POST['Email'],
         request.POST['FirstName'], request.POST['LastName'],
         request.POST['ContactPhone'], request.POST['OfficePhone'],
         request.POST['Extension'])
     if success is True:
         request.session.pop("editID", None)
         return render(request, ['shell/commands.html'])
     if success is False:
         request.session.pop("editID", None)
         return render(request, ['shell/editAccountError.html'])