- Timestamp:
- Nov 10, 2009, 9:56:28 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AppCoreController.groovy
r178 r185 3 3 class AppCoreController extends BaseController { 4 4 5 def authenticateService5 def personService 6 6 def createDataService 7 7 … … 17 17 */ 18 18 def welcome = { 19 def personInstance = Person.get(authenticateService.userDomain().id)19 def personInstance = personService.currentUser() 20 20 flash.message = "Welcome, ${personInstance.firstName} ${personInstance.lastName}." 21 21 … … 30 30 def changeSessionTimeout = { 31 31 if (request.method == 'GET') { 32 def personInstance = Person.get(authenticateService.userDomain().id)32 def personInstance = personService.currentUser() 33 33 return [ personInstance : personInstance ] 34 34 } 35 35 if (request.method == 'POST') { 36 def personInstance = Person.get(authenticateService.userDomain().id)36 def personInstance = personService.currentUser() 37 37 personInstance.properties = params 38 38 if (!personInstance.hasErrors() && personInstance.save(flush: true)) { … … 53 53 54 54 if (request.method == 'GET') { 55 def personInstance = Person.get(authenticateService.userDomain().id)55 def personInstance = personService.currentUser() 56 56 return [ personInstance : personInstance ] 57 57 } 58 58 59 59 if (request.method == 'POST') { 60 def personInstance = Person.get(authenticateService.userDomain().id)60 def personInstance = personService.currentUser() 61 61 62 62 if(params.confirmPass == params.pass) { -
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" -
trunk/grails-app/controllers/TaskDetailedController.groovy
r181 r185 4 4 class TaskDetailedController extends BaseController { 5 5 6 def authenticateService6 def personService 7 7 def dateUtilService 8 8 def taskService … … 29 29 { 30 30 def taskInstanceList = [] 31 def personInstance = Person.get(authenticateService.userDomain().id)31 def personInstance = personService.currentUser() 32 32 33 33 if(params.quickSearch == "searchMyTodays") { … … 39 39 taskInstanceList = taskSearchService.getInTheLastWeek(params) 40 40 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week." } 41 else { params.message = "No tasks found for t oday." }41 else { params.message = "No tasks found for the last week." } 42 42 } 43 43 else if(params.quickSearch == "searchMyInTheLastWeek") { 44 44 taskInstanceList = taskSearchService.getMyInTheLastWeek(params) 45 45 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week for ${personInstance.firstName} ${personInstance.lastName}." } 46 else { params.message = "No tasks found for t oday." }46 else { params.message = "No tasks found for the last week." } 47 47 } 48 48 else { … … 70 70 { 71 71 def taskInstanceList = [] 72 def personInstance = Person.get(authenticateService.userDomain().id)72 def personInstance = personService.currentUser() 73 73 74 74 if(params.quickSearch == "searchMyTodays") { … … 81 81 taskInstanceList = taskSearchService.getInTheLastWeek(params) 82 82 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week." } 83 else { params.message = "No tasks found for t oday." }83 else { params.message = "No tasks found for the last week." } 84 84 if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" } 85 85 } … … 87 87 taskInstanceList = taskSearchService.getMyInTheLastWeek(params) 88 88 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week for ${personInstance.firstName} ${personInstance.lastName}." } 89 else { params.message = "No tasks found for t oday." }89 else { params.message = "No tasks found for the last week." } 90 90 if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" } 91 91 } … … 117 117 { 118 118 def taskInstanceList = [] 119 def personInstance = Person.get(authenticateService.userDomain().id)119 def personInstance = personService.currentUser() 120 120 121 121 if(params.quickSearch == "budgetUnplanned") { … … 456 456 def taskInstance = new Task() 457 457 // Default leadPerson to current user. 458 taskInstance.leadPerson = Person.get(authenticateService.userDomain().id)458 taskInstance.leadPerson = personService.currentUser() 459 459 taskInstance.properties = params 460 460 return ['taskInstance':taskInstance] -
trunk/grails-app/services/CreateDataService.groovy
r182 r185 754 754 unitOfMeasure: UnitOfMeasure.get(2), 755 755 inventoryLocation: InventoryLocation.get(1), 756 name: " J-Rope",757 description: " Twine wound J-Rope",756 name: "Hemp rope", 757 description: "Natural hemp rope.", 758 758 unitsInStock: 2, 759 759 reorderPoint: 0) … … 765 765 unitOfMeasure: UnitOfMeasure.get(2), 766 766 inventoryLocation: InventoryLocation.get(1), 767 name: " L-Rope",768 description: " Twine wound L-Rope",767 name: "Cotton Rope 12mm", 768 description: "A soft natural rope made from cotton.", 769 769 alternateItems: InventoryItem.get(1), 770 770 unitsInStock: 2,
Note: See TracChangeset
for help on using the changeset viewer.