예제 #1
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)
예제 #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())
		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)
예제 #3
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)
예제 #4
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)
예제 #5
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)
예제 #6
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()
예제 #7
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()
예제 #8
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()