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