- Timestamp:
- Nov 10, 2009, 9:56:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/EntryDetailedController.groovy
r178 r185 3 3 class EntryDetailedController extends BaseController { 4 4 5 def authenticateService5 def personService 6 6 7 7 def index = { redirect(action:list,params:params) } … … 28 28 def entryInstance = Entry.get( params.id ) 29 29 if(entryInstance) { 30 if(entryInstance.enteredBy.loginName == authenticateService.userDomain().loginName) { 31 entryInstance.delete() 30 if(entryInstance.enteredBy.loginName == personService.currentUser().loginName) { 31 def taskID = entryInstance.task.id 32 entryInstance.delete(flush:true) 32 33 flash.message = "Entry ${params.id} deleted" 33 redirect( action:list)34 redirect(controller: 'taskDetailed', action: 'show', id: taskID) 34 35 } 35 36 else { … … 53 54 else { 54 55 55 if(entryInstance.enteredBy.loginName == authenticateService.userDomain().loginName) {56 if(entryInstance.enteredBy.loginName == personService.currentUser().loginName) { 56 57 return [ entryInstance : entryInstance ] 57 58 } … … 67 68 def entryInstance = Entry.get( params.id ) 68 69 if(entryInstance) { 69 entryInstance.properties = params 70 if(!entryInstance.hasErrors() && entryInstance.save(flush: true)) { 71 flash.message = "Entry ${params.id} updated" 72 redirect(action:show,id:entryInstance.id) 70 // The update method only accepts post requests, so this is just in case. 71 if(entryInstance.enteredBy.loginName == personService.currentUser().loginName) { 72 entryInstance.properties = params 73 if(!entryInstance.hasErrors() && entryInstance.save(flush: true)) { 74 flash.message = "Entry ${params.id} updated" 75 redirect(action:show,id:entryInstance.id) 76 } 77 else { 78 render(view:'edit',model:[entryInstance:entryInstance]) 79 } 73 80 } 74 81 else { 75 render(view:'edit',model:[entryInstance:entryInstance]) 82 flash.message = "You may only edit your own entries." 83 redirect(action:show,id:entryInstance.id) 76 84 } 77 85 } … … 98 106 def entryInstance = new Entry(params) 99 107 100 entryInstance.enteredBy = Person.get(authenticateService.userDomain().id)108 entryInstance.enteredBy = personService.currentUser() 101 109 if(!entryInstance.hasErrors() && entryInstance.save(flush: true)) { 102 110 flash.message = "Entry ${entryInstance.id} created"
Note: See TracChangeset
for help on using the changeset viewer.