dvdplm-taskr 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/taskr/controllers.rb +5 -3
- data/lib/taskr/models.rb +20 -4
- data/lib/taskr/version.rb +1 -1
- metadata +1 -1
data/lib/taskr/controllers.rb
CHANGED
@@ -176,7 +176,7 @@ module Taskr::Controllers
|
|
176
176
|
|
177
177
|
# Create and schedule a new task.
|
178
178
|
def create
|
179
|
-
|
179
|
+
$LOG.debug @input.inspect
|
180
180
|
begin
|
181
181
|
# the "0" is for compatibility with PHP's Zend_Rest_Client
|
182
182
|
task_data = @input[:task] || @input["0"] || @input
|
@@ -204,10 +204,12 @@ module Taskr::Controllers
|
|
204
204
|
if actions_data.kind_of?(Array)
|
205
205
|
actions = actions_data
|
206
206
|
elsif actions_data["0"]
|
207
|
+
$LOG.debug "Hash-ish"
|
207
208
|
actions = []
|
208
209
|
actions_data.each do |i,a|
|
209
210
|
actions << a
|
210
211
|
end
|
212
|
+
$LOG.debug "Converted hash into: #{actions.inspect}"
|
211
213
|
else
|
212
214
|
actions = actions_data[:action] || actions_data[:actions] || actions_data
|
213
215
|
end
|
@@ -233,7 +235,7 @@ module Taskr::Controllers
|
|
233
235
|
end
|
234
236
|
|
235
237
|
action = TaskAction.new(:order => a[:order] || i, :action_class_name => action_class_name)
|
236
|
-
|
238
|
+
$LOG.debug "Action should be initialized and ready for creation: #{action.inspect}"
|
237
239
|
|
238
240
|
action_class.parameters.each do |p|
|
239
241
|
value = a[p]
|
@@ -255,7 +257,7 @@ module Taskr::Controllers
|
|
255
257
|
|
256
258
|
@task.schedule! Taskr.scheduler
|
257
259
|
|
258
|
-
if @task.save
|
260
|
+
if @task.save!
|
259
261
|
location = "/tasks/#{@task.id}?format=#{@format}"
|
260
262
|
$LOG.debug "#{@task} saved successfuly. Setting Location header to #{location.inspect}."
|
261
263
|
@headers['Location'] = location
|
data/lib/taskr/models.rb
CHANGED
@@ -62,13 +62,29 @@ module Taskr::Models
|
|
62
62
|
|
63
63
|
$LOG.debug "Scheduling task #{name.inspect}: #{self.inspect}"
|
64
64
|
|
65
|
-
if task_actions
|
66
|
-
|
65
|
+
if self.new_record? # Need to distinguish between the edit/create cases. "Edit" needs to reload the task_actions or nothing works; "Create" needs NOT to relaod the actions, or the validations kick in and nothing works. FIXME!!!!!
|
66
|
+
if task_actions.length > 0
|
67
|
+
action = prepare_action
|
68
|
+
else
|
69
|
+
$LOG.warn "Task #{name.inspect} has no actions and as a result will not be scheduled!"
|
70
|
+
return false
|
71
|
+
end
|
67
72
|
else
|
68
|
-
|
69
|
-
|
73
|
+
if task_actions(true).length > 0
|
74
|
+
action = prepare_action
|
75
|
+
else
|
76
|
+
$LOG.warn "Task #{name.inspect} has no actions and as a result will not be scheduled!"
|
77
|
+
return false
|
78
|
+
end
|
70
79
|
end
|
71
80
|
|
81
|
+
# if task_actions(true).length > 0
|
82
|
+
# action = prepare_action
|
83
|
+
# else
|
84
|
+
# $LOG.warn "Task #{name.inspect} has no actions and as a result will not be scheduled!"
|
85
|
+
# return false
|
86
|
+
# end
|
87
|
+
|
72
88
|
job_id = scheduler.send(method, t || schedule_when, :schedulable => action)
|
73
89
|
|
74
90
|
if job_id
|
data/lib/taskr/version.rb
CHANGED