Module: Tasks::MovieLengthHandler

Included in:
WorkflowsController
Defined in:
app/models/tasks/movie_length_handler.rb

Instance Method Summary collapse

Instance Method Details

#do_movie_length_task(task, params) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/tasks/movie_length_handler.rb', line 8

def do_movie_length_task(task, params)
  ActiveRecord::Base.transaction do
    params[:asset].each do |asset_id, movie_length|
      asset = Receptacle.find(asset_id)

      unless task.valid_movie_length?(movie_length)
        flash[:error] = 'Invalid movie length'
        return false
      end

      asset.labware..update!(movie_length: movie_length)
    end
  end

  true
end

#render_movie_length_task(task, params) ⇒ Object


2
3
4
5
6
# File 'app/models/tasks/movie_length_handler.rb', line 2

def render_movie_length_task(task, params)
  @valid_movie_lengths = task.descriptors.find_by(name: 'Movie length').selection
  @default_movie_length = task.descriptors.find_by(name: 'Movie length').value.to_i
  @assets = task.find_batch_requests(params[:batch_id]).map(&:asset).uniq
end