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.
@@ -176,7 +176,7 @@ module Taskr::Controllers
176
176
 
177
177
  # Create and schedule a new task.
178
178
  def create
179
- puts @input.inspect
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
@@ -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(true).length > 0
66
- action = prepare_action
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
- $LOG.warn "Task #{name.inspect} has no actions and as a result will not be scheduled!"
69
- return false
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
@@ -2,7 +2,7 @@ module Taskr #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dvdplm-taskr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zukowski