Changeset 135 for trunk/grails-app/controllers
- Timestamp:
- May 13, 2009, 7:36:01 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskRecurringScheduleDetailedController.groovy
r134 r135 89 89 } 90 90 catch(Exception e) { 91 flash.message = "Please select a task, then Create a Recurring Schedule for it .'"91 flash.message = "Please select a task, then Create a Recurring Schedule for it" 92 92 redirect(controller:"taskDetailed", action:"list") 93 93 } … … 97 97 def taskRecurringScheduleInstance = new TaskRecurringSchedule(params) 98 98 def taskInstance = Task.get(params.task.id) 99 100 if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save()) { 99 100 if(taskInstance.taskRecurringSchedule) { 101 flash.message = "This task already has a recurring schedule" 102 redirect(controller:"taskDetailed", action:"show", id: params.task.id) 103 } 104 else { 101 105 102 taskInstance.taskRecurringSchedule = taskRecurringScheduleInstance 103 104 if(taskInstance.save()) { 105 flash.message = "TaskRecurringSchedule ${taskRecurringScheduleInstance.id} created" 106 redirect(action:show,id:taskRecurringScheduleInstance.id) 106 taskRecurringScheduleInstance.nextDueDate = new Date() 107 108 // taskRecurringScheduleInstance.nextDueDate = calculateNextDueDate(new Date()) 109 110 if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save()) { 111 112 taskInstance.taskRecurringSchedule = taskRecurringScheduleInstance 113 114 if(taskInstance.save()) { 115 flash.message = "TaskRecurringSchedule ${taskRecurringScheduleInstance.id} created" 116 redirect(action:show,id:taskRecurringScheduleInstance.id) 117 } 118 else { 119 flash.message = "Task could not be saved and therefore the Recurring Schedule has been disgarded, cause unknown." 120 render(view:'create',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance]) 121 } 107 122 } 108 123 else { 109 flash.message = "Task could not be saved and therefore the Recurring Schedule has been disgarded, cause unknown."110 124 render(view:'create',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance]) 111 125 } 112 }113 else {114 render(view:'create',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance])115 126 } 116 127 117 128 } 118 129 130 // private Date calculateNextDueDate(nextDue) { 131 // // def now = new Date() 132 // // def calculatedDays = new Integer() 133 // // def nextDue = new Date() 134 // 135 // // switch (period) { 136 // // case "Day(s)": 137 // // calculatedDays = period 138 // // nextDue = now + calculatedDays 139 // // case "Week(s)": 140 // // calculatedDays = period * 7 141 // // nextDue = now + calculatedDays 142 // // // default: 143 // // } 144 // nextDue = nextDue + 1 145 // return nextDue 146 // } 147 119 148 }
Note: See TracChangeset
for help on using the changeset viewer.