Changeset 147 for trunk/grails-app/controllers/PersonController.groovy
- Timestamp:
- Oct 8, 2009, 7:58:38 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/PersonController.groovy
r136 r147 4 4 class PersonController extends BaseAppAdminController { 5 5 6 def authenticateService 6 def authenticateService 7 def filterService 7 8 8 9 // the delete, save and update actions only accept POST requests … … 13 14 } 14 15 15 def list = { 16 if (!params.max) { 17 params.max = 10 18 } 19 [personList: Person.list(params)] 20 } 16 def list = { 17 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100 ) 18 19 if(!params.filter) 20 { return [personList: Person.list(params), personTotal: Person.count()] } 21 22 // filterPane: 23 return[ personList: filterService.filter( params, Person ), 24 personTotal: filterService.count( params, Person ), 25 filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params), 26 params:params ] 27 } 21 28 22 29 def show = { 30 31 // In the case of an actionSubmit button, rewrite action name from 'index'. 32 if(params._action_Show) 33 { params.action='show' } 34 23 35 def person = Person.get(params.id) 24 36 if (!person) { … … 46 58 if (person) { 47 59 def authPrincipal = authenticateService.principal() 48 // avoid self-delete if the logged-in user is an admin60 // Avoid self-delete. 49 61 if (!(authPrincipal instanceof String) && authPrincipal.username == person.loginName) { 50 flash.message = "You can not delete yourself, please login as another admin and try again" 62 flash.message = "You cannot delete yourself, please login as another manager and try again." 63 redirect(action:show,id:params.id) 51 64 } 52 65 else { 53 66 //first, delete this person from Persons_Authorities table. 54 67 Authority.findAll().each { it.removeFromPersons(person) } 55 68 person.isActive = false 69 person.save(flush: true) 70 56 71 try { 57 person.delete( )72 person.delete(flush: true) 58 73 flash.message = "Person $params.id deleted." 59 74 redirect(action:list) … … 72 87 def edit = { 73 88 89 // In the case of an actionSubmit button, rewrite action name from 'index'. 90 if(params._action_Edit) 91 { params.action='edit' } 92 74 93 def person = Person.get(params.id) 75 94 if (!person) { … … 78 97 return 79 98 } 80 99 flash.message = "To allow login at least the 'ROLE_AppUser' authority must be given." 81 100 return buildPersonModel(person) 82 101 } … … 126 145 127 146 def create = { 147 flash.message = "To allow login at least the 'ROLE_AppUser' authority must be given." 128 148 [person: new Person(params), authorityList: Authority.list()] 129 149 }
Note: See TracChangeset
for help on using the changeset viewer.