Ignore:
Timestamp:
Mar 16, 2011, 9:50:39 AM (14 years ago)
Author:
gav
Message:

Refactor logic into TaskService.checkCreateEntry().
Prevent entry creation on recurring tasks altogether.
Prevent entry creation other than PM Entries on tasks with a procedure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/EntryDetailedController.groovy

    r865 r873  
    113113        def taskInstance = Task.read(params.taskId)
    114114
    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             return
    119         }
    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             return
    126         }
    127 
    128         // Success.
    129115        def entryInstance = new Entry()
    130116        entryInstance.task = taskInstance
    131117        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.
    132128        def model = ['entryInstance': entryInstance]
    133129
Note: See TracChangeset for help on using the changeset viewer.