Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SpeedyAF when loading edit pages #6146

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/controllers/media_objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class MediaObjectsController < ApplicationController
include SecurityHelper

before_action :authenticate_user!, except: [:show, :set_session_quality, :show_stream_details, :manifest]
before_action :load_resource, except: [:create, :destroy, :update_status, :set_session_quality, :tree, :deliver_content, :confirm_remove, :show_stream_details, :add_to_playlist, :intercom_collections, :manifest, :move_preview, :edit, :update, :json_update]
load_and_authorize_resource except: [:create, :destroy, :update_status, :set_session_quality, :tree, :deliver_content, :confirm_remove, :show_stream_details, :add_to_playlist, :intercom_collections, :manifest, :move_preview, :show_progress]
authorize_resource only: [:create]
before_action :load_resource, except: [:create, :destroy, :update_status, :set_session_quality, :tree, :deliver_content, :confirm_remove, :show_stream_details, :add_to_playlist, :intercom_collections, :manifest, :move_preview, :update, :json_update]
load_and_authorize_resource except: [:create, :destroy, :update_status, :set_session_quality, :tree, :deliver_content, :confirm_remove, :show_stream_details, :add_to_playlist, :intercom_collections, :manifest, :move_preview, :show_progress, :edit]
authorize_resource only: [:create, :edit]

before_action :inject_workflow_steps, only: [:edit, :update], unless: proc { request.format.json? }
before_action :load_player_context, only: [:show]
Expand Down
8 changes: 8 additions & 0 deletions app/presenters/speedy_af/proxy/admin/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def to_model
self
end

def dropbox
Avalon::Dropbox.new( dropbox_absolute_path, self )
end

def dropbox_absolute_path( name = nil )
File.join(Settings.dropbox.path, name || dropbox_directory_name)
end

def persisted?
id.present?
end
Expand Down
12 changes: 12 additions & 0 deletions app/presenters/speedy_af/proxy/media_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
# specific language governing permissions and limitations under the License.
# --- END LICENSE_HEADER BLOCK ---

require 'active_model'

class SpeedyAF::Proxy::MediaObject < SpeedyAF::Base
extend ActiveModel::Translation

SINGULAR_FIELDS = [:title, :statement_of_responsibility, :date_created, :date_issued, :copyright_date, :abstract, :terms_of_use, :rights_statement]
HASH_FIELDS = [:note, :other_identifier, :related_item_url]

Expand Down Expand Up @@ -44,8 +48,12 @@ def initialize(solr_document, instance_defaults = {})
end
# Convert empty strings to nil
@attrs.transform_values! { |value| value == "" ? nil : value }
@errors = ActiveModel::Errors.new(self)
end

attr_accessor :name
attr_accessor :errors

def to_model
self
end
Expand Down Expand Up @@ -152,6 +160,10 @@ def permalink_with_query(query_vars = {})
val ? val.to_s : nil
end

def workflow
WorkflowDatastream.find("#{id}/workflow")
end

protected

# Overrides from SpeedyAF::Base
Expand Down
22 changes: 22 additions & 0 deletions config/initializers/workflow_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,26 @@
ResourceDescriptionStep.new,
StructureStep.new,
AccessControlStep.new)

# Override context building so edit page rendering skips fedora
Avalon::Workflow::WorkflowControllerBehavior.class_eval do
def model_object
@model_object = if params[:action] == "edit"
SpeedyAF::Base.find(params[:id])
else
ActiveFedora::Base.find(params[:id], cast: true)
end
end

# def perform_step_action action
# context = if action == :before_step
# HYDRANT_STEPS.get_step(@active_step).send(action, params.merge!({ user: user_key }))
# else
# HYDRANT_STEPS.get_step(@active_step).send(action, build_context)
# end

# context_to_instance_variables context
# context
# end
end
end