Example #1
0
	def disableButtons(self):
		super(ViewTableCompanies, self).disableButtons()
		row = self.ui.tableWidget.currentRow()
		disable = not appInst.isAdmin() or (not len(self.ui.tableWidget.selectedItems()) and \
			appInst.isAdmin()) or(len(self.ui.tableWidget.selectedItems()) and \
			appInst.isAdmin() and self.primaryKeys[row][0]['value'] == 1)
		self.ui.deleteRecordButton.setDisabled(disable)
Example #2
0
	def disableButtons(self):
		canAdd = appInst.isAdmin() or appInst.isManager()
		self.ui.addRecordButton.setDisabled(not canAdd)
		canChange = appInst.isAdmin() and len(self.ui.tableWidget.selectedItems())
		if len(self.ui.tableWidget.selectedItems()):
			row = self.ui.tableWidget.currentRow()
			projectEmpolyee = appInst.getRecord('projectEmployees', self.primaryKeys[row])
			canChange = canChange or (appInst.isManagerOnProject(projectEmpolyee.projectId) and\
				projectEmpolyee.employeeId != appInst.getEmployee().id)
		self.ui.editRecordButton.setDisabled(not canChange)
		self.ui.deleteRecordButton.setDisabled(not canChange)
Example #3
0
	def disableButtons(self):
		canAdd = appInst.isAdmin() or appInst.isManager()
		self.ui.addRecordButton.setDisabled(not canAdd)
		canChange = appInst.isAdmin() and len(self.ui.tableWidget.selectedItems())
		canDelete = False
		if len(self.ui.tableWidget.selectedItems()):
			row = self.ui.tableWidget.currentRow()
			task = appInst.getRecord('tasks', self.primaryKeys[row])
			canDelete = canChange or appInst.isManagerOnProject(task.projectId)
			canChange = canDelete or appInst.isTaskDeveloper(self.primaryKeys[row][0]['value'])
		self.ui.editRecordButton.setDisabled(not canChange)
		self.ui.deleteRecordButton.setDisabled(not canDelete)
Example #4
0
	def disableButtons(self):
		print 'dis'
		canAdd = appInst.isAdmin()
		self.ui.addRecordButton.setDisabled(not canAdd)
		canChange = appInst.isAdmin() and len(self.ui.tableWidget.selectedItems())
		if len(self.ui.tableWidget.selectedItems()):
			row = self.ui.tableWidget.currentRow()
			project = appInst.getRecord('projects', self.primaryKeys[row])
			canChange = canChange or appInst.isManagerOnProject(self.primaryKeys[row][0]['value'])
		self.ui.editRecordButton.setDisabled(not canChange)
		canDelete = canAdd and len(self.ui.tableWidget.selectedItems())
		self.ui.deleteRecordButton.setDisabled(not canDelete)
Example #5
0
	def disableButtons(self):
		canAdd = appInst.isAdmin() or appInst.isManager() or\
			appInst.isDeveloper()
		self.ui.addRecordButton.setDisabled(not canAdd)
		canChange = appInst.isAdmin() and len(self.ui.tableWidget.selectedItems())
		if len(self.ui.tableWidget.selectedItems()):
			row = self.ui.tableWidget.currentRow()
			job = appInst.getRecord('jobs', self.primaryKeys[row])
			task = dbi.query(Task).filter(Task.id == job.taskId).one()
			canChange = canChange or appInst.isManagerOnProject(task.projectId) or\
				appInst.isTaskDeveloper(task.id)
		self.ui.editRecordButton.setDisabled(not canChange)
		self.ui.deleteRecordButton.setDisabled(not canChange)
Example #6
0
	def disableButtons(self):
		self.ui.addRecordButton.setDisabled(not appInst.isAdmin())
		canDelete= (appInst.isAdmin() and len(self.ui.tableWidget.selectedItems()))
		canChange = canDelete
		if len(self.ui.tableWidget.selectedItems()):
			row = self.ui.tableWidget.currentRow()
			user = appInst.getRecord('users', self.primaryKeys[row])
			canChange = canChange or user.login == appInst.getLogin()
			canDelete = canDelete and user.login != appInst.getLogin()
		
		self.ui.editRecordButton.setDisabled(not canChange)
		#disable = disable or (user.admin and len(appInst.getAdmins()) == 1)
		self.ui.deleteRecordButton.setDisabled(not canDelete)
Example #7
0
	def disableButtons(self):
		canAdd = appInst.isAdmin() and appInst.getMaxTasksNumOnProjects()> 1 or\
			appInst.isManager() and appInst.getMaxTasksNumOnProjectsWithManager() > 1
		self.ui.addRecordButton.setDisabled(not canAdd)
		canChange = appInst.isAdmin() and len(self.ui.tableWidget.selectedItems())
		if len(self.ui.tableWidget.selectedItems()):
			row = self.ui.tableWidget.currentRow()
			taskDependency = appInst.getRecord('tasksDependencies', self.primaryKeys[row])
			project1 = appInst.getProjectByTask(taskDependency.masterId)
			project2 = appInst.getProjectByTask(taskDependency.slaveId)
			canChange = canChange or (appInst.isManagerOnProject(project1.id) and\
				project1.id == project2.id)
		self.ui.editRecordButton.setDisabled(not canChange)
		self.ui.deleteRecordButton.setDisabled(not canChange)
Example #8
0
	def checkCorrectness(self):
		super(ChangeRecordProjects, self).checkCorrectness()
		if not (self.rec or appInst.isAdmin()) or (self.rec and\
			not appInst.isAdmin() and (self.values[0]['value'] != self.rec.name or\
			datetime.datetime.strptime(str(self.values[1]['value']), "%Y-%m-%dT%H:%M:%S") != self.rec.startDate)):
			raise DBException('You have not permissions for this operation')
		if self.rec:
			startDate = self.values[1]['value']
			if len(dbi.session.execute('''select 1 from jobs as a, tasks as b, 
				projects as c where a.taskId = b.id and c.id = %s and 
				b.projectId = c.id and unix_timestamp(a.startDate) < %s - 2971032510''' % (
				self.keys[0]['value'], QtCore.QDateTime.fromString(startDate).toTime_t())).fetchall()):
				raise DBException('Task jobs can not start earlier than project')
		self.change()
Example #9
0
	def fillHeaders(self):
		#self.headers = appInst.getHeadersWithForeignValues(self.tableName)
		self.ui.tableWidget.setColumnCount(len(self.headers))
		self.ui.tableWidget.verticalHeader().setVisible(False)
		self.ui.tableWidget.setHorizontalHeaderLabels(self.headers)
		if not appInst.isAdmin():
			self.ui.addRecordButton.setDisabled(True)
Example #10
0
	def checkCorrectness(self):
		super(ChangeRecordUsers, self).checkCorrectness()
		if not (self.rec or appInst.isAdmin()) or (self.rec and\
			not appInst.isAdmin() and (self.values[2]['value'] != self.rec.admin or\
			self.values[0]['value'] != self.rec.login)):
			raise DBException('You have not permissions for this operation')
		correct = True
		for edit in self.edits:
			if edit.field == 'login':
				correct = correct and len(edit.text()) >= MIN_LOGIN_LENGTH
			elif edit.field == 'password':
				correct = correct and len(edit.text()) >= MIN_PASSWORD_LENGTH
		if not correct:
			raise DBException('Min login length is %d, min password length is%d'%(
				MIN_LOGIN_LENGTH, MIN_PASSWORD_LENGTH))
		self.change()
Example #11
0
	def checkCorrectness(self):
		super(ChangeRecordProjectEmployees, self).checkCorrectness()
		empl = self.values[0]['value']
		proj = self.values[1]['value']
		checkCorrectProjectAndContract(proj, empl)
		if not (appInst.isAdmin() or appInst.isManagerOnProject(self.values[1]['value'])):
			raise DBException('You have not permissions to assign developers on this project')
		if self.rec:
			if empl != self.rec.employeeId or proj != self.rec.projectId:
				if len(dbi.session.execute('''
					select 1 from tasks where employeeId = %s and projectId = %s
					and state <> %s''' % (self.rec.employeeId, self.rec.projectId,
					STAGE_TASK_FINISHED)).fetchall()):
						raise DBException('''Employee has unfinished tasks on other projects''')
		self.change()
Example #12
0
	def checkCorrectness(self):
		super(ChangeRecordJobs, self).checkCorrectness()
		if not len(dbi.session.execute('select 1 from tasks where employeeId = %s and id = %s' %(
			self.values[0]['value'], self.values[1]['value'])).fetchall()):
			raise DBException('Invalid pair: employee and task')
		task = dbi.query(Task).filter(Task.id == self.values[1]['value']).one()
		if task.state == STAGE_TASK_FINISHED:
			raise DBException('Task is finished')
		checkCorrectProjectAndContract(task.projectId, self.values[0]['value'])
		if not(appInst.isAdmin() or appInst.isTaskDeveloper(task.id) or\
			appInst.isManagerOnProject(task.projectId)):
			raise DBException('You have not permission for this operation')
		startDate = self.values[2]['value']
		completionDate = self.values[3]['value']
		if startDate >= completionDate:
			raise DBException('Start date must be earlier than completion date')
		projDate = dbi.session.execute('''select a.startDate from projects as a, tasks as b 
			where a.id = b.projectId and b.id = %s''' % self.values[1]['value']).fetchone()
		if datetime.datetime.strptime(str(startDate), "%Y-%m-%dT%H:%M:%S") < projDate[0]:
			raise DBException('Task jobs can not start earlier than project')
		
		self.change()
Example #13
0
	def checkCorrectness(self):
		super(ChangeRecordTasks, self).checkCorrectness()
		projectId = self.values[1]['value']
		employeeId = self.values[2]['value']
		checkCorrectProjectAndContract(projectId, employeeId)
		
		if not (appInst.isAdmin() or appInst.isManagerOnProject(projectId)):
			if not self.rec:
				raise DBException('You have not permissions to create tasks on this project')
			if not appInst.isTaskDeveloper(self.keys[0]['value']):
				raise DBException('You have not permissions to change this task')
				
			for val in self.values:
				if str(getattr(self.rec, val['name'])) != str(val['value']) and val['name'] != 'state':
					raise DBException('You have not permissions to change task attributes')
					
		if (self.rec and len(dbi.query(Task).filter(Task.employeeId == employeeId).filter(
			Task.state != STAGE_TASK_FINISHED).filter(Task.id != self.keys[0]['value']).all())) or\
			(not self.rec and len(dbi.query(Task).filter(Task.employeeId == employeeId).filter(
			Task.state != STAGE_TASK_FINISHED).all())):
			raise DBException('Employee has tasks in progress')
		if not len(dbi.session.execute('''select 1 from projectEmployees where projectId = %s 
			and employeeId = %s''' % (projectId, employeeId)).fetchall()):
			raise DBException('Invalid pair: employee and project')
		if self.rec:
			if self.checkBox.isChecked():
				if len(dbi.query(TasksDependency, Task).filter(TasksDependency.slaveId == 
					self.keys[0]['value']).filter(Task.id == TasksDependency.masterId).filter(
						Task.state != STAGE_TASK_FINISHED).all()):
					raise DBException('There are unfinished task dependencies')
			else:
				if len(dbi.session.execute('''select 1 from tasksDependencies as a, 
					tasks as b where a.masterId=%s and b.id=a.slaveId and b.state=%s''' %(
					self.keys[0]['value'], STAGE_TASK_FINISHED)).fetchall()):
					raise DBException('There are finished dependent tasks')
		self.change()
Example #14
0
	def disableButtons(self):
		disable = not (appInst.isAdmin() and len(self.ui.tableWidget.selectedItems()))
		self.ui.addRecordButton.setDisabled(not appInst.isAdmin())
		self.ui.editRecordButton.setDisabled(disable)
		self.ui.deleteRecordButton.setDisabled(disable)
Example #15
0
	def login(self, username, password):
		appInst.setCurUser(username, password)
		self.mainWindow.changeState('Hello, %s! %s' %(username, 
			"You're admin" if appInst.isAdmin() else ''))
		appInst.disableButtons()
		return appInst.curUser