Ignore:
Timestamp:
Feb 10, 2011, 12:17:55 PM (14 years ago)
Author:
gav
Message:

Task trash improvements.
Allow trashed parentTask to break subTask links (only with auth).
Prevent trashing of tasks linked to taskProcedure or Parent PM type tasks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/TaskService.groovy

    r749 r802  
    685685            }
    686686
     687            // Check for authorisation on tasks having subTasks.
     688            if(result.taskInstance.subTasks) {
     689                if(!authenticateService.ifAnyGranted('ROLE_AppAdmin,ROLE_Manager,ROLE_TaskManager'))
     690                    return fail(field:"subTasks", code:"task.operationNotPermittedOnTaskHavingSubTasksWithoutAuth")
     691            }
     692
     693            // Check for taskProcedure using this task as linkedTask.
     694            if(result.taskInstance.taskProcedure?.linkedTask?.id == result.taskInstance.id)
     695                return fail(field:"taskProcedure", code:"task.operationNotPermittedOnTaskLinkedToProcedure")
     696
     697            // Check for Parent PM task type.
     698            if(result.taskInstance.taskType.id == 6)
     699                return fail(field:"taskProcedure", code:"task.operationNotPermittedOnParentPmTask")
     700
    687701            result.taskInstance.trash = true
    688702            result.taskInstance.attentionFlag = false
    689703            result.taskInstance.taskRecurringSchedule?.enabled = false
     704            result.taskInstance.subTasks.each {
     705                it.parentTask = null
     706            }
    690707
    691708            if(result.taskInstance.hasErrors() || !result.taskInstance.save())
Note: See TracChangeset for help on using the changeset viewer.