module Fiona7 class ReleaseController < ActionController::Base def release obj_ids = params[:objs] comment = params[:comment] errors = [] if !obj_ids.empty? main_obj = obj_ids.shift carefully_release(errors, main_obj, comment) obj_ids.each do |other_obj| carefully_release(errors, other_obj) end end render json: {} end def preview self.in_rtc_workspace do @obj = WriteObj.find(params[:id]) @recursive = Fiona7::RecursiveObjectFinder.new(@obj) @images = @recursive.images.select {|o| o.really_edited? } @downloads = @recursive.downloads.select {|o| o.really_edited? } @referenced = @recursive.referenced.select {|o| o.really_edited? } @linked = @recursive.linked.select {|o| o.really_edited? } render "preview", layout: false end end protected def in_rtc_workspace(&block) Scrivito::Workspace.find('rtc').as_current(&block) end def carefully_release(errors, obj, comment=nil) obj.take obj.release!(comment) complex_object = Fiona7::ComplexObject.new(obj) complex_object.widgets.each do |widget_obj| widget_obj.take widget_obj.release!(comment) end #complex_object.binaries.each do |widget_obj| # widget_obj.take # widget_obj.release!(comment) #end rescue => e Rails.logger.error("Error occured when releasing #{@obj.id}: unable to release Object with ID #{obj.id} (#{obj.path} because: #{e.inspect}") # TODO: translate error = "Unable to release Object with ID #{obj.id} because: #{e.message}" errors << error end end end