Skip to content

Commit 4608126

Browse files
authored
Merge pull request #6146 from avalonmediasystem/speedy_edit
Use SpeedyAF when loading edit pages
2 parents f69d3f8 + af90198 commit 4608126

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

app/controllers/concerns/workflow_controller_behavior.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,13 @@ def update
9090
def custom_update
9191
end
9292

93+
# Use SpeedyAF for loading edit pages more quickly, switch to fedora for saves
9394
def model_object
94-
@model_object ||= ActiveFedora::Base.find(params[:id], cast: true)
95+
@model_object ||= if params[:action] == "edit"
96+
SpeedyAF::Base.find(params[:id])
97+
else
98+
ActiveFedora::Base.find(params[:id], cast: true)
99+
end
95100
end
96101

97102
def build_context

app/controllers/media_objects_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class MediaObjectsController < ApplicationController
2323
include SecurityHelper
2424

2525
before_action :authenticate_user!, except: [:show, :set_session_quality, :show_stream_details, :manifest]
26-
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]
27-
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]
28-
authorize_resource only: [:create]
26+
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]
27+
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]
28+
authorize_resource only: [:create, :edit]
2929

3030
before_action :inject_workflow_steps, only: [:edit, :update], unless: proc { request.format.json? }
3131
before_action :load_player_context, only: [:show]

app/presenters/speedy_af/proxy/admin/collection.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ def to_model
3131
self
3232
end
3333

34+
def dropbox
35+
Avalon::Dropbox.new( dropbox_absolute_path, self )
36+
end
37+
38+
def dropbox_absolute_path( name = nil )
39+
File.join(Settings.dropbox.path, name || dropbox_directory_name)
40+
end
41+
3442
def persisted?
3543
id.present?
3644
end

app/presenters/speedy_af/proxy/media_object.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
# specific language governing permissions and limitations under the License.
1313
# --- END LICENSE_HEADER BLOCK ---
1414

15+
require 'active_model'
16+
1517
class SpeedyAF::Proxy::MediaObject < SpeedyAF::Base
18+
extend ActiveModel::Translation
19+
1620
SINGULAR_FIELDS = [:title, :statement_of_responsibility, :date_created, :date_issued, :copyright_date, :abstract, :terms_of_use, :rights_statement]
1721
HASH_FIELDS = [:note, :other_identifier, :related_item_url]
1822

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

54+
attr_accessor :name
55+
attr_accessor :errors
56+
4957
def to_model
5058
self
5159
end
@@ -156,6 +164,10 @@ def permalink_with_query(query_vars = {})
156164
val ? val.to_s : nil
157165
end
158166

167+
def workflow
168+
WorkflowDatastream.find("#{id}/workflow")
169+
end
170+
159171
protected
160172

161173
# Overrides from SpeedyAF::Base

spec/factories/media_objects.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
physical_description { [Faker::Lorem.word] }
4343
table_of_contents { [Faker::Lorem.paragraph] }
4444
note { [{ note: Faker::Lorem.paragraph, type: 'general' }, { note: Faker::Lorem.paragraph, type: 'local' }] }
45-
other_identifier { [{ id: Faker::Lorem.word, source: 'local' }] }
45+
other_identifier { [{ id: Faker::Lorem.unique.word, source: 'local' }] }
4646
language { ['eng'] }
4747
related_item_url { [{ url: Faker::Internet.url, label: Faker::Lorem.sentence }]}
48-
bibliographic_id { { id: Faker::Lorem.word, source: 'local' } }
48+
bibliographic_id { { id: Faker::Lorem.unique.word, source: 'local' } }
4949
comment { ['MO comment'] }
5050
rights_statement { ['http://rightsstatements.org/vocab/InC-EDU/1.0/'] }
5151
terms_of_use { [ 'Terms of Use: Be kind. Rewind.' ] }

0 commit comments

Comments
 (0)