Index: trunk/grails-app/controllers/TaskDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 180)
+++ trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 181)
@@ -11,6 +11,6 @@
     def exportService
 
-    // the delete, save and update actions only accept POST requests
-    static allowedMethods = [delete:'POST', save:'POST', update:'POST']
+    // these actions only accept POST requests
+    static allowedMethods = [save:'POST', update:'POST', restore:'POST', trash:'POST', approve:'POST', renegeApproval:'POST', complete:'POST', reopen:'POST']
 
     def index = { redirect(action:search,params:params) }
@@ -223,21 +223,152 @@
     }
 
-    def delete = {
-        def taskInstance = Task.get( params.id )
-        if(taskInstance) {
-            try {
-                taskInstance.isActive = false
-                flash.message = "Task ${params.id} has been set to inactive."
-                redirect(action:search)
-            }
-            catch(org.springframework.dao.DataIntegrityViolationException e) {
-                flash.message = "Task ${params.id} could not be deleted"
-                redirect(action:show,id:params.id)
-            }
-        }
-        else {
+    def restore = {
+
+        if(!Task.exists(params.id)) {
             flash.message = "Task not found with id ${params.id}"
-            redirect(action:search)
-        }
+            redirect(action:'search')
+        }
+
+        def result = taskService.restore(params)
+
+        if(!result.error) {
+                flash.message = "Task ${params.id} has been restored."
+                redirect(action:show,id:result.taskInstance.id)
+        }
+        else {
+            if(result.taskInstance) {
+                render(view:'edit',model:[taskInstance:result.taskInstance])
+            }
+            else {
+                flash.message = "Task could not be updated."
+                redirect(action:'search')
+            }
+        }
+
+    }
+
+    def trash = {
+
+        if(!Task.exists(params.id)) {
+            flash.message = "Task not found with id ${params.id}."
+            redirect(action:'search')
+        }
+
+        def result = taskService.trash(params)
+
+        if(!result.error) {
+                flash.message = "Task ${params.id} has been moved to trash."
+                redirect(action:'search')
+        }
+        else {
+            if(result.taskInstance) {
+                render(view:'edit',model:[taskInstance:result.taskInstance])
+            }
+            else {
+                flash.message = "Task could not be updated."
+                redirect(action:'search')
+            }
+        }
+
+    }
+
+    def approve = {
+
+        if(!Task.exists(params.id)) {
+            flash.message = "Task not found with id ${params.id}."
+            redirect(action:'search')
+        }
+
+        def result = taskService.approve(params)
+
+        if(!result.error) {
+                flash.message = "Task ${params.id} has been approved."
+                redirect(action:show,id:result.taskInstance.id)
+        }
+        else {
+            if(result.taskInstance) {
+                render(view:'edit',model:[taskInstance:result.taskInstance])
+            }
+            else {
+                flash.message = "Task could not be updated."
+                redirect(action:'search')
+            }
+        }
+
+    }
+
+    def renegeApproval = {
+
+        if(!Task.exists(params.id)) {
+            flash.message = "Task not found with id ${params.id}."
+            redirect(action:'search')
+        }
+
+        def result = taskService.renegeApproval(params)
+
+        if(!result.error) {
+                flash.message = "Task ${params.id} has had approval removed."
+                redirect(action:show,id:result.taskInstance.id)
+        }
+        else {
+            if(result.taskInstance) {
+                render(view:'edit',model:[taskInstance:result.taskInstance])
+            }
+            else {
+                flash.message = "Task could not be updated."
+                redirect(action:'search')
+            }
+        }
+
+    }
+
+    def complete = {
+
+        if(!Task.exists(params.id)) {
+            flash.message = "Task not found with id ${params.id}."
+            redirect(action:'search')
+        }
+
+        def result = taskService.complete(params)
+
+        if(!result.error) {
+                flash.message = "Task ${params.id} has been completed."
+                redirect(action:show,id:result.taskInstance.id)
+        }
+        else {
+            if(result.taskInstance) {
+                render(view:'edit',model:[taskInstance:result.taskInstance])
+            }
+            else {
+                flash.message = "Task could not be updated."
+                redirect(action:'search')
+            }
+        }
+
+    }
+
+    def reopen = {
+
+        if(!Task.exists(params.id)) {
+            flash.message = "Task not found with id ${params.id}."
+            redirect(action:'search')
+        }
+
+        def result = taskService.reopen(params)
+
+        if(!result.error) {
+                flash.message = "Task ${params.id} has been reopened."
+                redirect(action:show,id:result.taskInstance.id)
+        }
+        else {
+            if(result.taskInstance) {
+                render(view:'edit',model:[taskInstance:result.taskInstance])
+            }
+            else {
+                flash.message = "Task could not be updated."
+                redirect(action:'search')
+            }
+        }
+
     }
 
@@ -255,4 +386,8 @@
         }
         else {
+            if(taskInstance.trash) {
+                flash.message = "You may not edit items in the trash."
+                redirect(action:show,id:taskInstance.id)
+            }
             def criteria = taskInstance.createCriteria()
             def possibleParentList = criteria {
@@ -320,4 +455,6 @@
     def create = {
         def taskInstance = new Task()
+        // Default leadPerson to current user.
+        taskInstance.leadPerson = Person.get(authenticateService.userDomain().id)
         taskInstance.properties = params
         return ['taskInstance':taskInstance]
