- Timestamp:
- Mar 16, 2011, 9:50:39 AM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/EntryDetailedController.groovy
r865 r873 113 113 def taskInstance = Task.read(params.taskId) 114 114 115 if(!taskInstance) {116 params.errorMessage = g.message(code:"default.not.found", args:['Task',params.taskId])117 render(contentType:"text/json", status: 403, template: "/shared/messages")118 return119 }120 121 // Check for Complete task.122 if(taskInstance.taskStatus.id == 3) {123 params.errorMessage = g.message(code:"task.operationNotPermittedOnCompleteTask")124 render(contentType:"text/json", status: 403, template: "/shared/messages")125 return126 }127 128 // Success.129 115 def entryInstance = new Entry() 130 116 entryInstance.task = taskInstance 131 117 entryInstance.entryType = EntryType.read(params.entryTypeId) 118 119 // Check if we should create this entry. 120 def checkResult = taskService.checkCreateEntry(entryInstance) 121 if(checkResult.error) { 122 params.errorMessage = g.message(code: checkResult.error.code) 123 render(contentType:"text/json", status: 403, template: "/shared/messages") 124 return 125 } 126 127 // Success. 132 128 def model = ['entryInstance': entryInstance] 133 129 -
trunk/grails-app/i18n/messages.properties
r860 r873 156 156 task.operationNotPermittedOnCompleteTask=This operation is not permitted on a complete task. 157 157 task.operationNotPermittedOnTaskInTrash=This operation is not permitted on a task that is in the trash. 158 task.operationNotPermittedOnRecurringTask=This operation is not permitted \ 159 on a recurring task, please see the Sub Tasks. 158 160 task.operationNotPermittedOnRecurringTaskWithoutAuth=This operation is not permitted \ 159 161 on a recurring task without authorisation. … … 164 166 task.operationNotPermittedOnParentPmTask=This operation is not permitted \ 165 167 on a Parent PM task. 168 task.createEntryNotPermittedOnTaskWithProcedure=This operation is not permitted \ 169 on a task with a procedure, please create entries on the procedure tab. 166 170 task.failedToSave=Could not complete operation, task failed to save. 167 171 task.modifications.failedToSave=Could not complete operation, as task modification record failed to save. -
trunk/grails-app/services/TaskService.groovy
r851 r873 338 338 } 339 339 340 if(!taskInstance) 341 return fail(field:"task", code:"task.notFound") 342 343 if(taskInstance.taskStatus.id == 3) 344 return fail(field:"task", code:"task.operationNotPermittedOnCompleteTask") 345 346 // Check for authorisation on recurring tasks. 347 if(taskInstance.taskRecurringSchedule) { 348 if(!authenticateService.ifAnyGranted('ROLE_AppAdmin,ROLE_Manager,ROLE_TaskManager')) 349 return fail(field:"task", code:"task.operationNotPermittedOnRecurringTaskWithoutAuth") 350 } 340 // Check if we should create this entry. 341 def checkResult = checkCreateEntry(result.entryInstance) 342 if(checkResult.error) 343 return fail(field:"task", code: checkResult.error.code) 351 344 352 345 if(result.entryInstance.hasErrors() || !result.entryInstance.save()) … … 1065 1058 } // end saveImmediateCallout() 1066 1059 1060 /** 1061 * Check if we should create an entry. 1062 * @param entryInstance The entry to check. 1063 * @returns A map containing result.error (if any error) and result.taskInstance. 1064 */ 1065 def checkCreateEntry(entryInstance) { 1066 def result = [:] 1067 1068 def fail = { Map m -> 1069 result.error = [ code: m.code, args: [] ] 1070 return result 1071 } 1072 1073 def taskInstance = entryInstance.task 1074 if(!taskInstance) 1075 return fail(code:"task.notFound") 1076 1077 // Check for tashed task. 1078 if(taskInstance.trash) 1079 return fail(code:"task.operationNotPermittedOnTaskInTrash") 1080 1081 // Check for Complete task. 1082 if(taskInstance.taskStatus.id == 3) 1083 return fail(code: "task.operationNotPermittedOnCompleteTask") 1084 1085 // Check for recurring schedule. 1086 if(taskInstance.taskRecurringSchedule) 1087 return fail(code:"task.operationNotPermittedOnRecurringTask") 1088 1089 // Check for procedure and ensure we are creating a PM Entry. 1090 if(taskInstance.taskProcedureRevision && (entryInstance.entryType.id != 6) ) 1091 return fail(code:"task.createEntryNotPermittedOnTaskWithProcedure") 1092 1093 // Success. 1094 return result 1095 1096 } // checkCreateEntry() 1097 1067 1098 } // end TaskService
Note: See TracChangeset
for help on using the changeset viewer.