Exemplo n.º 1
0
	def __init__(self):
		QtGui.QMainWindow.__init__(self)
		self.ui = Ui_adminWindow()
		self.ui.setupUi(self)
		self.setGeometry(300, 100, 750, 520)
		self.ui.schoolSaved.hide()
		self.ui.studentSaved.hide()
		self.ui.courseAdded.hide()
		self.ui.passwordChanged.hide()
		self.ui.editUpdateNotif.hide()
		self.ui.studentNotFound.hide()
		self.ui.studentRecordSuccess.hide()
		self.ui.dataEditContainer.hide()
		self.ui.studentRecorded.hide()
		self.databag = function.dict_object('data.json')
		school = self.databag['school']
		self.ui.schoolName.setText(school)
		self.ui.schoolNameBtn.clicked.connect(self.addSchool)
		self.ui.changePassBtn.clicked.connect(self.changePass)
		self.ui.addDeptBtn.clicked.connect(self.addDepartment)
		self.ui.addStudentBtn.clicked.connect(self.addStudent)
		self.ui.editStudentBtn.clicked.connect(self.editStudent)
		self.ui.updateStudentBtn.clicked.connect(self.updateStudent)
		self.ui.deleteDeptBtn.clicked.connect(self.deleteDepartment)
		self.ui.deleteCourseBtn.clicked.connect(self.deleteCourse)
		self.ui.DeptEditBtn.clicked.connect(self.editDept)
		self.ui.CourseEditBtn.clicked.connect(self.editCourse)

		# Departments Combo Box
		for x, department in enumerate(self.databag['departments']):
			self.ui.courseAddDeptList.addItem('')
			self.ui.deptEditSelect.addItem('')
			self.ui.studentDept.addItem('')
			self.ui.ed_department.addItem('')
			self.ui.courseAddDeptList.setItemText(x, department)
			self.ui.deptEditSelect.setItemText(x, department)
			self.ui.studentDept.setItemText(x, department)
			self.ui.ed_department.setItemText(x, department)
		self.ui.DeptEdit.setText( str( self.ui.deptEditSelect.currentText() ) )

		# Dependent Courses Combo Box
		presentDeptCourses = str( self.ui.deptEditSelect.currentText() )
		for x, course in enumerate(self.databag['departments'][presentDeptCourses]):
			self.ui.courseEditSelect.addItem('')
			self.ui.courseEditSelect.setItemText(x, course)
		
		self.ui.CourseEdit.setText( str(self.ui.courseEditSelect.currentText()) )

		self.ui.deptEditSelect.currentIndexChanged.connect(self.updateCourseList)
		self.ui.courseEditSelect.currentIndexChanged.connect(self.updateCourseEdit)
		self.ui.addCourseBtn.clicked.connect(self.addCourses)
		#Menu Actions
		self.ui.actionQuit.triggered.connect(self.close)
		self.ui.actionDocumentation.triggered.connect(function.openGitPage)
		self.ui.actionAbout.triggered.connect(about.show)
		self.ui.actionCredits.triggered.connect(credits.show)
		self.ui.actionLicense.triggered.connect(license.show)
		self.ui.actionAdmin_Logout.triggered.connect(self.closeAdmin)
Exemplo n.º 2
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.ui = Ui_adminWindow()
        self.ui.setupUi(self)
        self.setGeometry(300, 100, 750, 520)
        self.ui.schoolSaved.hide()
        self.ui.studentSaved.hide()
        self.ui.courseAdded.hide()
        self.ui.passwordChanged.hide()
        self.ui.editUpdateNotif.hide()
        self.ui.studentNotFound.hide()
        self.ui.studentRecordSuccess.hide()
        self.ui.dataEditContainer.hide()
        self.ui.studentRecorded.hide()
        self.databag = function.dict_object('data.json')
        school = self.databag['school']
        self.ui.schoolName.setText(school)
        self.ui.schoolNameBtn.clicked.connect(self.addSchool)
        self.ui.changePassBtn.clicked.connect(self.changePass)
        self.ui.addDeptBtn.clicked.connect(self.addDepartment)
        self.ui.addStudentBtn.clicked.connect(self.addStudent)
        self.ui.editStudentBtn.clicked.connect(self.editStudent)
        self.ui.updateStudentBtn.clicked.connect(self.updateStudent)
        self.ui.deleteDeptBtn.clicked.connect(self.deleteDepartment)
        self.ui.deleteCourseBtn.clicked.connect(self.deleteCourse)
        self.ui.DeptEditBtn.clicked.connect(self.editDept)
        self.ui.CourseEditBtn.clicked.connect(self.editCourse)

        # Departments Combo Box
        for x, department in enumerate(self.databag['departments']):
            self.ui.courseAddDeptList.addItem('')
            self.ui.deptEditSelect.addItem('')
            self.ui.studentDept.addItem('')
            self.ui.ed_department.addItem('')
            self.ui.courseAddDeptList.setItemText(x, department)
            self.ui.deptEditSelect.setItemText(x, department)
            self.ui.studentDept.setItemText(x, department)
            self.ui.ed_department.setItemText(x, department)
        self.ui.DeptEdit.setText(str(self.ui.deptEditSelect.currentText()))

        # Dependent Courses Combo Box
        presentDeptCourses = str(self.ui.deptEditSelect.currentText())
        for x, course in enumerate(
                self.databag['departments'][presentDeptCourses]):
            self.ui.courseEditSelect.addItem('')
            self.ui.courseEditSelect.setItemText(x, course)

        self.ui.CourseEdit.setText(str(self.ui.courseEditSelect.currentText()))

        self.ui.deptEditSelect.currentIndexChanged.connect(
            self.updateCourseList)
        self.ui.courseEditSelect.currentIndexChanged.connect(
            self.updateCourseEdit)
        self.ui.addCourseBtn.clicked.connect(self.addCourses)
        #Menu Actions
        self.ui.actionQuit.triggered.connect(self.close)
        self.ui.actionDocumentation.triggered.connect(function.openGitPage)
        self.ui.actionAbout.triggered.connect(about.show)
        self.ui.actionCredits.triggered.connect(credits.show)
        self.ui.actionLicense.triggered.connect(license.show)
        self.ui.actionAdmin_Logout.triggered.connect(self.closeAdmin)
Exemplo n.º 3
0
class administrationView(QtGui.QMainWindow):
	"""Displays administrator window"""
	def __init__(self):
		QtGui.QMainWindow.__init__(self)
		self.ui = Ui_adminWindow()
		self.ui.setupUi(self)
		self.setGeometry(300, 100, 750, 520)
		self.ui.schoolSaved.hide()
		self.ui.studentSaved.hide()
		self.ui.courseAdded.hide()
		self.ui.passwordChanged.hide()
		self.ui.editUpdateNotif.hide()
		self.ui.studentNotFound.hide()
		self.ui.studentRecordSuccess.hide()
		self.ui.dataEditContainer.hide()
		self.ui.studentRecorded.hide()
		self.databag = function.dict_object('data.json')
		school = self.databag['school']
		self.ui.schoolName.setText(school)
		self.ui.schoolNameBtn.clicked.connect(self.addSchool)
		self.ui.changePassBtn.clicked.connect(self.changePass)
		self.ui.addDeptBtn.clicked.connect(self.addDepartment)
		self.ui.addStudentBtn.clicked.connect(self.addStudent)
		self.ui.editStudentBtn.clicked.connect(self.editStudent)
		self.ui.updateStudentBtn.clicked.connect(self.updateStudent)
		self.ui.deleteDeptBtn.clicked.connect(self.deleteDepartment)
		self.ui.deleteCourseBtn.clicked.connect(self.deleteCourse)
		self.ui.DeptEditBtn.clicked.connect(self.editDept)
		self.ui.CourseEditBtn.clicked.connect(self.editCourse)

		# Departments Combo Box
		for x, department in enumerate(self.databag['departments']):
			self.ui.courseAddDeptList.addItem('')
			self.ui.deptEditSelect.addItem('')
			self.ui.studentDept.addItem('')
			self.ui.ed_department.addItem('')
			self.ui.courseAddDeptList.setItemText(x, department)
			self.ui.deptEditSelect.setItemText(x, department)
			self.ui.studentDept.setItemText(x, department)
			self.ui.ed_department.setItemText(x, department)
		self.ui.DeptEdit.setText( str( self.ui.deptEditSelect.currentText() ) )

		# Dependent Courses Combo Box
		presentDeptCourses = str( self.ui.deptEditSelect.currentText() )
		for x, course in enumerate(self.databag['departments'][presentDeptCourses]):
			self.ui.courseEditSelect.addItem('')
			self.ui.courseEditSelect.setItemText(x, course)
		
		self.ui.CourseEdit.setText( str(self.ui.courseEditSelect.currentText()) )

		self.ui.deptEditSelect.currentIndexChanged.connect(self.updateCourseList)
		self.ui.courseEditSelect.currentIndexChanged.connect(self.updateCourseEdit)
		self.ui.addCourseBtn.clicked.connect(self.addCourses)
		#Menu Actions
		self.ui.actionQuit.triggered.connect(self.close)
		self.ui.actionDocumentation.triggered.connect(function.openGitPage)
		self.ui.actionAbout.triggered.connect(about.show)
		self.ui.actionCredits.triggered.connect(credits.show)
		self.ui.actionLicense.triggered.connect(license.show)
		self.ui.actionAdmin_Logout.triggered.connect(self.closeAdmin)

	def editCourse(self):
		currentIndex = self.ui.courseEditSelect.currentIndex()
		currentDept = str( self.ui.deptEditSelect.currentText() )
		currentCourse = str( self.ui.courseEditSelect.currentText() )
		value = str( self.ui.CourseEdit.text() )
		self.databag['departments'][currentDept][currentIndex] = value
		function.dump_data(self.databag)
		function.talk('Course name changed')
		self.ui.editUpdateNotif.show()
		QtCore.QTimer.singleShot(1000 * 10, self.ui.editUpdateNotif.hide)
		self.ui.courseEditSelect.setItemText(currentIndex, value)

	def editDept(self):
		currentIndex = self.ui.deptEditSelect.currentIndex()
		currentDept = str( self.ui.deptEditSelect.currentText() )
		value = str( self.ui.DeptEdit.text() )
		self.databag['departments'][value] = self.databag['departments'].pop(currentDept)
		function.dump_data(self.databag)
		function.talk('department name changed')
		self.ui.editUpdateNotif.show()
		QtCore.QTimer.singleShot(1000 * 10, self.ui.editUpdateNotif.hide)
		self.ui.deptEditSelect.setItemText(currentIndex, value)

	def deleteCourse(self):
		currentIndex = self.ui.courseEditSelect.currentIndex()
		currentDept = str( self.ui.deptEditSelect.currentText() )
		currentCourse = str( self.ui.courseEditSelect.currentText() )
		self.databag['departments'][currentDept].remove(currentCourse)
		function.dump_data(self.databag)
		self.ui.editUpdateNotif.show()
		function.talk('course has been deleted')
		QtCore.QTimer.singleShot(1000 * 10, self.ui.editUpdateNotif.hide)
		self.ui.courseEditSelect.removeItem(currentIndex)

	def deleteDepartment(self):
		currentIndex = self.ui.deptEditSelect.currentIndex()
		currentDept = str( self.ui.deptEditSelect.currentText() )
		self.databag['departments'].pop(currentDept)
		function.dump_data(self.databag)
		self.ui.editUpdateNotif.show()
		function.talk('department deleted')
		QtCore.QTimer.singleShot(1000 * 10, self.ui.editUpdateNotif.hide)
		self.ui.deptEditSelect.removeItem(currentIndex)

	def editStudent(self):
		enteredId = str( self.ui.matricEditEntry.text() )
		if self.databag['students'].has_key(enteredId):
			self.ui.studentNotFound.hide()
			self.ui.studentRecordSuccess.hide()
			self.ui.ed_studentName.setText( self.databag['students'][enteredId][0] )
			self.ui.ed_studentID.setText(enteredId)
			for x, department in enumerate(self.databag['departments']):
				if department == self.databag['students'][enteredId][1]:
					self.ui.ed_department.setCurrentIndex(x)
			self.ui.ed_image.setText( self.databag['students'][enteredId][2] )
			self.ui.dataEditContainer.show()
		else:
			self.ui.dataEditContainer.hide()
			self.ui.studentNotFound.show()
			QtCore.QTimer.singleShot(1000 * 5, self.ui.studentNotFound.hide)

	def updateStudent(self):
		studentID = str( self.ui.ed_studentID.text() )
		name = str( self.ui.ed_studentName.text() )
		studentDept = str( self.ui.ed_department.currentText() )
		studentImage = str( self.ui.ed_image.text() )
		if not studentID or not name or not studentDept:
			self.ui.studentRecorded.show()
			QtCore.QTimer.singleShot(1000 * 10, self.ui.studentRecorded.hide)
		else:
			enteredId = str( self.ui.matricEditEntry.text() )
			currentCourses = self.databag['students'][enteredId][3]
			self.databag['students'][enteredId] = [name, studentDept, studentImage, currentCourses]
			self.databag['students'][studentID] = self.databag['students'].pop(enteredId)
			self.ui.matricEditEntry.clear()
			self.ui.dataEditContainer.hide()
			self.ui.studentRecordSuccess.show()
			QtCore.QTimer.singleShot(1000 * 10, self.ui.studentRecordSuccess.hide)
			function.dump_data(self.databag)


	def updateCourseList(self):
		self.ui.DeptEdit.setText( str( self.ui.deptEditSelect.currentText() ) )
		presentDeptCourses = str( self.ui.deptEditSelect.currentText() )
		for x, course in enumerate(self.databag['departments'][presentDeptCourses]):
			self.ui.courseEditSelect.addItem('')
			self.ui.courseEditSelect.setItemText(x, course)
		
		self.ui.CourseEdit.setText( str(self.ui.courseEditSelect.currentText()) )
	def updateCourseEdit(self):
		self.ui.CourseEdit.setText( str(self.ui.courseEditSelect.currentText()) )

	def addSchool(self):
		self.databag['school'] = str( self.ui.schoolName.text() )
		function.dump_data(self.databag)
		self.ui.schoolSaved.show()
		QtCore.QTimer.singleShot(1000 * 5, self.ui.schoolSaved.hide)
		function.talk('School name saved')
	def addDepartment(self):
		deptInput = str( self.ui.addDept.text() )
		if not deptInput:
			self.ui.addDeptNotice.setText("Empty Input")
			function.talk('Empty Input')
		else:
			self.databag['departments'][deptInput] = []
			function.dump_data(self.databag)
			self.ui.addDeptNotice.setText('Department Saved')
			self.ui.addDept.clear()
			self.ui.courseAddDeptList.addItem(deptInput)
			self.ui.deptEditSelect.addItem(deptInput)
			self.ui.studentDept.addItem(deptInput)
			self.ui.ed_department.addItem(deptInput)
			function.talk("Department saved")
	def addCourses(self):
		courseName = str( self.ui.addCourse.text() )
		if courseName == '':
			function.talk('Empty Input')
		else:
			selectedDepartment = str( self.ui.courseAddDeptList.currentText() )
			self.databag['departments'][selectedDepartment].append(courseName)
			function.dump_data(self.databag)
			self.ui.addCourse.clear()
			self.ui.courseAdded.show()
			function.talk("Course added")
			QtCore.QTimer.singleShot(1000 * 3, self.ui.courseAdded.hide)
	def addStudent(self):
		surname = str( self.ui.surname.text() )
		others = str( self.ui.othernames.text() )
		department = str( self.ui.studentDept.currentText() )
		campusID = str( self.ui.campusID.text() )
		avatar = str( self.ui.studentImage.text() )
		# Form Validation
		if surname == '':
			self.ui.studentSaved.setText("Surname field is required")
			self.ui.studentSaved.show()
		elif others == '':
			self.ui.studentSaved.setText("Other names field is required")
			self.ui.studentSaved.show()
		elif campusID == '':
			self.ui.studentSaved.setText("Campus ID is required")
			self.ui.studentSaved.show()
		elif campusID in self.databag['students']:
			self.ui.studentSaved.setText("A student exists with that ID")
			self.ui.studentSaved.show()
		else:
			self.databag['students'][campusID] = [ surname + ' ' + others, department,avatar,'']
			function.talk('Student has been added')
			self.ui.studentSaved.setText("Student Saved")
			self.ui.studentSaved.show()
			function.dump_data(self.databag)
			self.ui.surname.clear()
			self.ui.othernames.clear()
			self.ui.campusID.clear()
			self.ui.studentImage.clear()
			QtCore.QTimer.singleShot(1000 * 3, self.ui.studentSaved.hide)
	def changePass(self):
		"""Changes administrator's password"""
		newpass = str( self.ui.passwordChange.text() )
		if newpass == '':
			self.ui.passwordChanged.setText('Password Field cannot be left blank')
			self.ui.passwordChanged.show()
			function.talk('password empty!')
		else:
			self.databag['auth'] = str(function.computeHash(newpass))
			function.dump_data(self.databag)
			self.ui.passwordChanged.setText('Password Updated')
			self.ui.passwordChanged.show()
			self.ui.passwordChange.clear()
			function.talk('password updated')
	def closeAdmin(self):
		self.hide()
		window.show()
Exemplo n.º 4
0
class administrationView(QtGui.QMainWindow):
    """Displays administrator window"""
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.ui = Ui_adminWindow()
        self.ui.setupUi(self)
        self.setGeometry(300, 100, 750, 520)
        self.ui.schoolSaved.hide()
        self.ui.studentSaved.hide()
        self.ui.courseAdded.hide()
        self.ui.passwordChanged.hide()
        self.ui.editUpdateNotif.hide()
        self.ui.studentNotFound.hide()
        self.ui.studentRecordSuccess.hide()
        self.ui.dataEditContainer.hide()
        self.ui.studentRecorded.hide()
        self.databag = function.dict_object('data.json')
        school = self.databag['school']
        self.ui.schoolName.setText(school)
        self.ui.schoolNameBtn.clicked.connect(self.addSchool)
        self.ui.changePassBtn.clicked.connect(self.changePass)
        self.ui.addDeptBtn.clicked.connect(self.addDepartment)
        self.ui.addStudentBtn.clicked.connect(self.addStudent)
        self.ui.editStudentBtn.clicked.connect(self.editStudent)
        self.ui.updateStudentBtn.clicked.connect(self.updateStudent)
        self.ui.deleteDeptBtn.clicked.connect(self.deleteDepartment)
        self.ui.deleteCourseBtn.clicked.connect(self.deleteCourse)
        self.ui.DeptEditBtn.clicked.connect(self.editDept)
        self.ui.CourseEditBtn.clicked.connect(self.editCourse)

        # Departments Combo Box
        for x, department in enumerate(self.databag['departments']):
            self.ui.courseAddDeptList.addItem('')
            self.ui.deptEditSelect.addItem('')
            self.ui.studentDept.addItem('')
            self.ui.ed_department.addItem('')
            self.ui.courseAddDeptList.setItemText(x, department)
            self.ui.deptEditSelect.setItemText(x, department)
            self.ui.studentDept.setItemText(x, department)
            self.ui.ed_department.setItemText(x, department)
        self.ui.DeptEdit.setText(str(self.ui.deptEditSelect.currentText()))

        # Dependent Courses Combo Box
        presentDeptCourses = str(self.ui.deptEditSelect.currentText())
        for x, course in enumerate(
                self.databag['departments'][presentDeptCourses]):
            self.ui.courseEditSelect.addItem('')
            self.ui.courseEditSelect.setItemText(x, course)

        self.ui.CourseEdit.setText(str(self.ui.courseEditSelect.currentText()))

        self.ui.deptEditSelect.currentIndexChanged.connect(
            self.updateCourseList)
        self.ui.courseEditSelect.currentIndexChanged.connect(
            self.updateCourseEdit)
        self.ui.addCourseBtn.clicked.connect(self.addCourses)
        #Menu Actions
        self.ui.actionQuit.triggered.connect(self.close)
        self.ui.actionDocumentation.triggered.connect(function.openGitPage)
        self.ui.actionAbout.triggered.connect(about.show)
        self.ui.actionCredits.triggered.connect(credits.show)
        self.ui.actionLicense.triggered.connect(license.show)
        self.ui.actionAdmin_Logout.triggered.connect(self.closeAdmin)

    def editCourse(self):
        currentIndex = self.ui.courseEditSelect.currentIndex()
        currentDept = str(self.ui.deptEditSelect.currentText())
        currentCourse = str(self.ui.courseEditSelect.currentText())
        value = str(self.ui.CourseEdit.text())
        self.databag['departments'][currentDept][currentIndex] = value
        function.dump_data(self.databag)
        function.talk('Course name changed')
        self.ui.editUpdateNotif.show()
        QtCore.QTimer.singleShot(1000 * 10, self.ui.editUpdateNotif.hide)
        self.ui.courseEditSelect.setItemText(currentIndex, value)

    def editDept(self):
        currentIndex = self.ui.deptEditSelect.currentIndex()
        currentDept = str(self.ui.deptEditSelect.currentText())
        value = str(self.ui.DeptEdit.text())
        self.databag['departments'][value] = self.databag['departments'].pop(
            currentDept)
        function.dump_data(self.databag)
        function.talk('department name changed')
        self.ui.editUpdateNotif.show()
        QtCore.QTimer.singleShot(1000 * 10, self.ui.editUpdateNotif.hide)
        self.ui.deptEditSelect.setItemText(currentIndex, value)

    def deleteCourse(self):
        currentIndex = self.ui.courseEditSelect.currentIndex()
        currentDept = str(self.ui.deptEditSelect.currentText())
        currentCourse = str(self.ui.courseEditSelect.currentText())
        self.databag['departments'][currentDept].remove(currentCourse)
        function.dump_data(self.databag)
        self.ui.editUpdateNotif.show()
        function.talk('course has been deleted')
        QtCore.QTimer.singleShot(1000 * 10, self.ui.editUpdateNotif.hide)
        self.ui.courseEditSelect.removeItem(currentIndex)

    def deleteDepartment(self):
        currentIndex = self.ui.deptEditSelect.currentIndex()
        currentDept = str(self.ui.deptEditSelect.currentText())
        self.databag['departments'].pop(currentDept)
        function.dump_data(self.databag)
        self.ui.editUpdateNotif.show()
        function.talk('department deleted')
        QtCore.QTimer.singleShot(1000 * 10, self.ui.editUpdateNotif.hide)
        self.ui.deptEditSelect.removeItem(currentIndex)

    def editStudent(self):
        enteredId = str(self.ui.matricEditEntry.text())
        if self.databag['students'].has_key(enteredId):
            self.ui.studentNotFound.hide()
            self.ui.studentRecordSuccess.hide()
            self.ui.ed_studentName.setText(
                self.databag['students'][enteredId][0])
            self.ui.ed_studentID.setText(enteredId)
            for x, department in enumerate(self.databag['departments']):
                if department == self.databag['students'][enteredId][1]:
                    self.ui.ed_department.setCurrentIndex(x)
            self.ui.ed_image.setText(self.databag['students'][enteredId][2])
            self.ui.dataEditContainer.show()
        else:
            self.ui.dataEditContainer.hide()
            self.ui.studentNotFound.show()
            QtCore.QTimer.singleShot(1000 * 5, self.ui.studentNotFound.hide)

    def updateStudent(self):
        studentID = str(self.ui.ed_studentID.text())
        name = str(self.ui.ed_studentName.text())
        studentDept = str(self.ui.ed_department.currentText())
        studentImage = str(self.ui.ed_image.text())
        if not studentID or not name or not studentDept:
            self.ui.studentRecorded.show()
            QtCore.QTimer.singleShot(1000 * 10, self.ui.studentRecorded.hide)
        else:
            enteredId = str(self.ui.matricEditEntry.text())
            currentCourses = self.databag['students'][enteredId][3]
            self.databag['students'][enteredId] = [
                name, studentDept, studentImage, currentCourses
            ]
            self.databag['students'][studentID] = self.databag['students'].pop(
                enteredId)
            self.ui.matricEditEntry.clear()
            self.ui.dataEditContainer.hide()
            self.ui.studentRecordSuccess.show()
            QtCore.QTimer.singleShot(1000 * 10,
                                     self.ui.studentRecordSuccess.hide)
            function.dump_data(self.databag)

    def updateCourseList(self):
        self.ui.DeptEdit.setText(str(self.ui.deptEditSelect.currentText()))
        presentDeptCourses = str(self.ui.deptEditSelect.currentText())
        for x, course in enumerate(
                self.databag['departments'][presentDeptCourses]):
            self.ui.courseEditSelect.addItem('')
            self.ui.courseEditSelect.setItemText(x, course)

        self.ui.CourseEdit.setText(str(self.ui.courseEditSelect.currentText()))

    def updateCourseEdit(self):
        self.ui.CourseEdit.setText(str(self.ui.courseEditSelect.currentText()))

    def addSchool(self):
        self.databag['school'] = str(self.ui.schoolName.text())
        function.dump_data(self.databag)
        self.ui.schoolSaved.show()
        QtCore.QTimer.singleShot(1000 * 5, self.ui.schoolSaved.hide)
        function.talk('School name saved')

    def addDepartment(self):
        deptInput = str(self.ui.addDept.text())
        if not deptInput:
            self.ui.addDeptNotice.setText("Empty Input")
            function.talk('Empty Input')
        else:
            self.databag['departments'][deptInput] = []
            function.dump_data(self.databag)
            self.ui.addDeptNotice.setText('Department Saved')
            self.ui.addDept.clear()
            self.ui.courseAddDeptList.addItem(deptInput)
            self.ui.deptEditSelect.addItem(deptInput)
            self.ui.studentDept.addItem(deptInput)
            self.ui.ed_department.addItem(deptInput)
            function.talk("Department saved")

    def addCourses(self):
        courseName = str(self.ui.addCourse.text())
        if courseName == '':
            function.talk('Empty Input')
        else:
            selectedDepartment = str(self.ui.courseAddDeptList.currentText())
            self.databag['departments'][selectedDepartment].append(courseName)
            function.dump_data(self.databag)
            self.ui.addCourse.clear()
            self.ui.courseAdded.show()
            function.talk("Course added")
            QtCore.QTimer.singleShot(1000 * 3, self.ui.courseAdded.hide)

    def addStudent(self):
        surname = str(self.ui.surname.text())
        others = str(self.ui.othernames.text())
        department = str(self.ui.studentDept.currentText())
        campusID = str(self.ui.campusID.text())
        avatar = str(self.ui.studentImage.text())
        # Form Validation
        if surname == '':
            self.ui.studentSaved.setText("Surname field is required")
            self.ui.studentSaved.show()
        elif others == '':
            self.ui.studentSaved.setText("Other names field is required")
            self.ui.studentSaved.show()
        elif campusID == '':
            self.ui.studentSaved.setText("Campus ID is required")
            self.ui.studentSaved.show()
        elif campusID in self.databag['students']:
            self.ui.studentSaved.setText("A student exists with that ID")
            self.ui.studentSaved.show()
        else:
            self.databag['students'][campusID] = [
                surname + ' ' + others, department, avatar, ''
            ]
            function.talk('Student has been added')
            self.ui.studentSaved.setText("Student Saved")
            self.ui.studentSaved.show()
            function.dump_data(self.databag)
            self.ui.surname.clear()
            self.ui.othernames.clear()
            self.ui.campusID.clear()
            self.ui.studentImage.clear()
            QtCore.QTimer.singleShot(1000 * 3, self.ui.studentSaved.hide)

    def changePass(self):
        """Changes administrator's password"""
        newpass = str(self.ui.passwordChange.text())
        if newpass == '':
            self.ui.passwordChanged.setText(
                'Password Field cannot be left blank')
            self.ui.passwordChanged.show()
            function.talk('password empty!')
        else:
            self.databag['auth'] = str(function.computeHash(newpass))
            function.dump_data(self.databag)
            self.ui.passwordChanged.setText('Password Updated')
            self.ui.passwordChanged.show()
            self.ui.passwordChange.clear()
            function.talk('password updated')

    def closeAdmin(self):
        self.hide()
        window.show()