def test_logout(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) Terminal.login(user, user.username, user.password) self.assertEquals(Terminal.logout(user), "Successfully Logged Out")
def get(self, request): terminalInstance = Terminal() user = USER.objects.get(id=request.session['userid']) terminalInstance.login(user.username, user.password) aList = A_LIST.objects.all() iList = I_LIST.objects.all() instructorCourses = [] for entry in iList: if entry.instructorID is user.id: instructorCourses.append(entry.courseID) instructorAssistants = [] for entry in iList: if instructorCourses.__contains__( entry.instructorID) and entry.instructorID != user.id: instructorAssistants.append(entry.instructorID) assistantAssignments = [] for entry in aList: if instructorAssistants.__contains__(entry.assistantID): assistantAssignments.append([entry.assistantID, entry.labID]) allCourses = COURSE.objects.all() courseList = [] for course in allCourses: if instructorCourses.__contains__(course.id): courseList.append([ course.id, course.name, course.courseNumber, course.classNumber, course.time, course.location ]) allLabs = LAB_SECTION.objects.all() labList = [] for lab in allLabs: if instructorCourses.__contains__(int(lab.courseID)): labList.append([ lab.id, lab.name, lab.courseID, lab.labNumber, lab.time, lab.location ]) allUsers = USER.objects.all() assistantList = [] for entry in allUsers: if instructorAssistants.__contains__(entry.id): assistantList.append( [entry.id, entry.firstName, entry.lastName]) return render( request, 'shell/instructorAssignAssistantToLab.html/', { "courseList": courseList, "labList": labList, "assistants": assistantList, "assistantAssignments": assistantAssignments })
def get(self, request): terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) ret, bool = terminalInstance.accessData() if (bool == False): render(request, 'shell/error.html') return render(request, 'shell/editContactInfo.html')
def post(self, request): terminalInstance = Terminal() user = USER.objects.get(id=int(request.session['userid'])) terminalInstance.login(user.username, user.password) ret, success = terminalInstance.assignInstructorToCourse( int(request.POST['courseID']), int(request.POST['instructorID'])) if success == True: return redirect('/commands/') if success == False: return render(request, 'shell/error.html/', {"message": ret})
def get(self, request): terminalInstance = Terminal() user = USER.objects.get(id=request.session['userid']) terminalInstance.login(user.username, user.password) courseAssociations = I_LIST.objects.all() labAssociations = A_LIST.objects.all() instructorCourses = [] assistantAssociations = [] for entry in courseAssociations: if int(entry.instructorID) is user.id: instructorCourses.append(int(entry.courseID)) for entry in courseAssociations: if instructorCourses.__contains__(entry.courseID): assistantAssociations.append(int(entry.instructorID)) assistants = [] assignments = [] allUsers = USER.objects.all() for user in allUsers: if assistantAssociations.__contains__(user.id): assistants.append([user.id, user.username]) for entry in labAssociations: if entry.assistantID is user.id: assignments.append( [user.id, user.username, entry.labID]) courses = [] labs = [] for courseID in instructorCourses: course = COURSE.objects.get(id=courseID) courses.append([ course.id, course.name, course.courseNumber, course.classNumber, course.time, course.location ]) try: labQuery = LAB_SECTION.objects.filter(courseID=courseID) for lab in labQuery: labs.append([ lab.id, lab.name, lab.courseID, lab.labNumber, lab.time, lab.location ]) except LAB_SECTION.DoesNotExist: pass return render( request, 'shell/viewAssistants.html', { "assistants": assistants, "assignments": assignments, "courses": courses, "labs": labs })
def get(self, request): terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) ret, bool = terminalInstance.accessData() if (bool == True): allCourses = ret[1] return render(request, 'shell/editCourse.html', {"allCourses": allCourses}) return render(request, 'shell/editCourse.html')
def get(self, request): terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) allUsers, bool = terminalInstance.viewContactInfo() if (bool == False): render(request, 'shell/error.html') return render(request, 'shell/viewContactInfo.html', {"allUsers": allUsers})
def post(self, request): terminalInstance = Terminal() user = USER.objects.get(id=request.session['userid']) terminalInstance.login(user.username, user.password) ret, success = terminalInstance.deleteLab(int(request.POST['labID'])) if success is False: return render(request, 'shell/error.html', {"message": ret}) return redirect('/commands/')
def get(self, request): terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) ret, bool = terminalInstance.accessData() if (bool == False): render(request, 'shell/error.html') allCourses = ret[1] return render(request, 'shell/createLab.html', {'allCourses': allCourses})
def post(self, request): terminalInstance = Terminal() user = USER.objects.get(id=request.session['userid']) terminalInstance.login(user.username, user.password) id = request.POST['courseid'] name = request.POST['coursename'] coursenumber = request.POST['coursenumber'] classnumber = request.POST['classnumber'] classtime = request.POST['time'] location = request.POST['location'] terminalInstance.editCourse(id, name, coursenumber, classnumber, classtime, location) return redirect('/commands/')
def post(self, request): terminalInstance = Terminal() user = USER.objects.get(id=request.session['userid']) terminalInstance.login(user.username, user.password) Courseid = request.POST['CourseId'] assistantid = request.POST['AssistantId'] ret, success = terminalInstance.assignAssistantToCourse( int(Courseid), int(assistantid)) if success is False: return render(request, 'shell/error.html', {"message": ret}) return redirect('/commands/')
def post(self, request): terminalInstance = Terminal() user = USER.objects.get(id=request.session['userid']) terminalInstance.login(user.username, user.password) ret, success = terminalInstance.createLab( request.POST['name'], int(request.POST['courseID']), request.POST['labNumber'], request.POST['time'], request.POST['location']) if success is False: return render(request, 'shell/error.html', {"message": ret}) return redirect('/commands/')
def test_login(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) self.assertEquals(Terminal.login(user, user.username, user.password), "Login Successful") self.assertEquals(Terminal.login(user, user.username, 'wrong'), "Invalid Login") self.assertEquals(Terminal.login('IPPPO', user.password), "Invalid Login") self.assertEquals(Terminal.login('IPPPPOOOOO', 'wronggggggg'), "Invalid Login")
def get(self, request): terminalInstance = Terminal() user = USER.objects.get(id=request.session['userid']) terminalInstance.login(user.username, user.password) courseAssociations = I_LIST.objects.filter(instructorID=user.id) courseList = [] for entry in courseAssociations: course = COURSE.objects.get(id=entry.courseID) courseList.append([ course.id, course.name, course.courseNumber, course.classNumber, course.time, course.location ]) return render(request, 'shell/viewCourses.html', {"courseList": courseList})
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'])
def post(self, request): email = request.POST['email'] contactPhone = request.POST['contactPhone'] officePhone = request.POST['officePhone'] extension = request.POST['extension'] terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) response, boole = terminalInstance.editContactInfo( email, contactPhone, officePhone, extension) if boole: request.method = 'get' return redirect('/commands/') else: return redirect('shell/createAccountError.html')
def get(self, request): terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) ret, bool = terminalInstance.accessData() if (bool == False): render(request, 'shell/error.html') allUsers = ret[0] allCourses = ret[1] allLabs = ret[2] assistantAssignments = ret[3] instructorAssignments = ret[4] return render( request, 'shell/accessAllData.html', { "allUsers": allUsers, "allCourses": allCourses, "allLabs": allLabs, "assistantAssignments": assistantAssignments, "instructorAssignments": instructorAssignments })
def get(self, request): terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) ret, success = terminalInstance.accessData() if (success == False): render(request, 'shell/error.html') #allUsers=[] #for i in ret[0]: # if i.permission.__contains__('3'): # allUsers = allUsers + i allUsers = USER.objects.filter(permission='3') allCourses = ret[1] instructorAssignments = ret[4] return render( request, 'shell/assignInstructorToCourse.html', { 'allUsers': allUsers, 'allCourses': allCourses, 'instructorAssignments': instructorAssignments })
def post(self, request): username = request.POST['username'] password = request.POST['password'] permission = request.POST['permission'] email = request.POST['email'] firstName = request.POST['firstName'] lastName = request.POST['lastName'] contactPhone = request.POST['contactPhone'] officePhone = request.POST['officePhone'] extension = request.POST['extension'] terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) ret, success = terminalInstance.createAccount(permission, username, password, email, firstName, lastName, contactPhone, officePhone, extension) if success is True: request.method = 'get' return redirect('/commands/') else: return render(request, '/error/', {"message": ret})
def post(self, request): terminalInstance = Terminal() username = request.POST['UserName'] password = request.POST['Password'] response = terminalInstance.login(username, password) if response.__contains__(False): return render(request, 'shell/loginError.html', {'res': response[0]}) else: user = USER.objects.get(username=username) request.session['userid'] = user.id userPermissions = [] for i in user.permission: if i.__eq__("1") or i.__eq__("2") or i.__eq__("3") or i.__eq__( "4"): userPermissions.append(i) request.session['permissions'] = userPermissions request.session['activePermission'] = userPermissions[0] return HttpResponseRedirect('/commands/')