- Timestamp:
- Apr 4, 2009, 6:41:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/grails-app/controllers/EntryDetailedController.groovy
r91 r98 28 28 def entryInstance = Entry.get( params.id ) 29 29 if(entryInstance) { 30 entryInstance.delete() 31 flash.message = "Entry ${params.id} deleted" 32 redirect(action:list) 30 if(entryInstance.enteredBy.loginName == authenticateService.userDomain().loginName) { 31 entryInstance.delete() 32 flash.message = "Entry ${params.id} deleted" 33 redirect(action:list) 34 } 35 else { 36 flash.message = "You may only delete your own entries." 37 redirect(action:show,id:entryInstance.id) 38 } 39 33 40 } 34 41 else { … … 40 47 def edit = { 41 48 def entryInstance = Entry.get( params.id ) 42 43 49 if(!entryInstance) { 44 flash.message = "Entry not found with id ${params.id}"45 redirect(action:list)50 flash.message = "Entry not found with id ${params.id}" 51 redirect(action:list) 46 52 } 47 53 else { 48 return [ entryInstance : entryInstance ] 54 55 if(entryInstance.enteredBy.loginName == authenticateService.userDomain().loginName) { 56 return [ entryInstance : entryInstance ] 57 } 58 else { 59 flash.message = "You may only edit your own entries." 60 redirect(action:show,id:entryInstance.id) 61 } 62 49 63 } 50 64 } … … 69 83 70 84 def create = { 71 def entryInstance = new Entry() 72 entryInstance.properties = params 73 return ['entryInstance':entryInstance] 85 try { 86 def taskInstance = Task.get(params.taskInstance.id) 87 def entryInstance = new Entry() 88 entryInstance.task = taskInstance 89 return ['entryInstance':entryInstance] 90 } 91 catch(Exception e) { 92 flash.message = "Please select a task, then 'Add Entry'" 93 redirect(controller:"taskDetailed", action:"list") 94 } 74 95 } 75 96
Note: See TracChangeset
for help on using the changeset viewer.