Ejemplo n.º 1
0
	def checkCorrectness(self):
		super(ChangeRecordTaskDependencies, self).checkCorrectness()
		masterId = int(self.values[0]['value'])
		slaveId = int(self.values[1]['value'])
		project1 = appInst.getProjectByTask(masterId)
		project2 = appInst.getProjectByTask(slaveId)
		if project1.id != project2.id:
			raise DBException('Chosen tasks must belong to the same project')
		if masterId == slaveId:
			raise DBException('Chosen tasks must be different')
		graph, maxTaskId = appInst.getTasksDependencyGraph(slaveId)
		if graph:
			graph[slaveId].append(masterId)
			vis = [False for i in range(maxTaskId + 1)]
			
			def dfs(v):
				if vis[v]:
					return True
				vis[v] = True
				for i in graph[v]:
					if dfs(i):
						return True
				vis[v] = False
				return False
				
			if dfs(slaveId):
				raise DBException('Cycle detected')
				
		self.change()
Ejemplo n.º 2
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)