source: branches/TaskRewrite/src/grails-app/controllers/TaskTypeController.groovy @ 71

Last change on this file since 71 was 69, checked in by gav, 15 years ago

Add TaskPriority? and TaskType? domains, generate views and controllers.
Tweak security extensively.
Use 'extend BaseController?' to pass ROLE_USER to most controllers.
Add parentTask and subTask to Task Domain.

File size: 2.6 KB
Line 
1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
2
3class TaskTypeController extends BaseController {
4   
5    def index = { redirect(action:list,params:params) }
6
7    // the delete, save and update actions only accept POST requests
8    def allowedMethods = [delete:'POST', save:'POST', update:'POST']
9
10    def list = {
11        if(!params.max) params.max = 10
12        [ taskTypeInstanceList: TaskType.list( params ) ]
13    }
14
15    def show = {
16        def taskTypeInstance = TaskType.get( params.id )
17
18        if(!taskTypeInstance) {
19            flash.message = "TaskType not found with id ${params.id}"
20            redirect(action:list)
21        }
22        else { return [ taskTypeInstance : taskTypeInstance ] }
23    }
24
25    def delete = {
26        def taskTypeInstance = TaskType.get( params.id )
27        if(taskTypeInstance) {
28            taskTypeInstance.delete()
29            flash.message = "TaskType ${params.id} deleted"
30            redirect(action:list)
31        }
32        else {
33            flash.message = "TaskType not found with id ${params.id}"
34            redirect(action:list)
35        }
36    }
37
38    def edit = {
39        def taskTypeInstance = TaskType.get( params.id )
40
41        if(!taskTypeInstance) {
42            flash.message = "TaskType not found with id ${params.id}"
43            redirect(action:list)
44        }
45        else {
46            return [ taskTypeInstance : taskTypeInstance ]
47        }
48    }
49
50    def update = {
51        def taskTypeInstance = TaskType.get( params.id )
52        if(taskTypeInstance) {
53            taskTypeInstance.properties = params
54            if(!taskTypeInstance.hasErrors() && taskTypeInstance.save()) {
55                flash.message = "TaskType ${params.id} updated"
56                redirect(action:show,id:taskTypeInstance.id)
57            }
58            else {
59                render(view:'edit',model:[taskTypeInstance:taskTypeInstance])
60            }
61        }
62        else {
63            flash.message = "TaskType not found with id ${params.id}"
64            redirect(action:edit,id:params.id)
65        }
66    }
67
68    def create = {
69        def taskTypeInstance = new TaskType()
70        taskTypeInstance.properties = params
71        return ['taskTypeInstance':taskTypeInstance]
72    }
73
74    def save = {
75        def taskTypeInstance = new TaskType(params)
76        if(!taskTypeInstance.hasErrors() && taskTypeInstance.save()) {
77            flash.message = "TaskType ${taskTypeInstance.id} created"
78            redirect(action:show,id:taskTypeInstance.id)
79        }
80        else {
81            render(view:'create',model:[taskTypeInstance:taskTypeInstance])
82        }
83    }
84}
Note: See TracBrowser for help on using the repository browser.