Skip to content

Commit

Permalink
Adds route, controller action, presenter, and view for inspect_work
Browse files Browse the repository at this point in the history
  • Loading branch information
randalldfloyd committed Oct 27, 2016
1 parent 81cb7b9 commit 258f58e
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module CurationConcerns::CurationConcernController

module ClassMethods
def curation_concern_type=(curation_concern_type)
load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager]
load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager, :inspect_work]
self._curation_concern_type = curation_concern_type
end

Expand Down Expand Up @@ -103,6 +103,10 @@ def file_manager
presenter
end

def inspect_work
presenter
end

attr_writer :actor

protected
Expand Down
52 changes: 52 additions & 0 deletions app/presenters/curation_concerns/inspect_work_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module CurationConcerns
class InspectWorkPresenter
def initialize(solr_document, current_ability)
@solr_document = solr_document
@current_ability = current_ability
end
attr_reader :solr_document, :current_ability

def workflow
if sipity_entity
{
entity_id: sipity_entity.id,
proxy_for: sipity_entity.proxy_for_global_id,
workflow_id: sipity_entity.workflow_id,
workflow_name: sipity_entity.workflow_name,
state_id: sipity_entity.workflow_state_id,
state_name: sipity_entity.workflow_state_name,
roles: sipity_role # TO-DO How to get related roles and actors for the sipity_entity
}
end
end

def solr
work.to_solr if work
end

def storage
work.inspect if work
end

private

def sipity_entity
@sipity_entity ||= PowerConverter.convert(solr_document, to: :sipity_entity)
rescue PowerConverter::ConversionError
nil
end

def sipity_role
# TO-DO How to use PowerConverter to get info on roles for a sipity_entity
'Not impmlemented'
end

def sipity_actor
# TO-DO How to use PowerConverter to get info on actors for a sipity_role
end

def work
@work ||= sipity_entity.proxy_for if sipity_entity
end
end
end
4 changes: 4 additions & 0 deletions app/presenters/curation_concerns/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def workflow
@workflow ||= WorkflowPresenter.new(solr_document, current_ability)
end

def inspect_work
@inspect_workflow ||= InspectWorkPresenter.new(solr_document, current_ability)
end

# @return FileSetPresenter presenter for the representative FileSets
def representative_presenter
return nil if representative_id.blank?
Expand Down
29 changes: 29 additions & 0 deletions app/views/curation_concerns/base/inspect_work.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<h1><%= t("inspect_work.link_text") %></h1>
<ul class="breadcrumb">
<li>
Back to <%= link_to @presenter.to_s, [main_app, @presenter] %>
</li>
</ul>

<h3>Workflow</h3>
<dl>
<% workflow = @presenter.inspect_work.workflow %>
<dt>Object Name</dt>
<dd><%= @presenter.to_s %></dd>
<dt>Processing Entity ID</dt>
<dd><%= workflow[:entity_id] %> (Proxy for <%= workflow[:proxy_for] %>)</dd>
<dt>Workflow Name</dt>
<dd><%= workflow[:workflow_name] %> (ID=<%= workflow[:workflow_id] %>)</dd>
<dt>Workflow State</dt>
<dd><%= workflow[:state_name] %> (ID=<%= workflow[:state_id] %>)</dd>
<dt>Roles</dt>
<dd><%= workflow[:roles] %></dd>

<h3>Storage</h3>
<dl>
<dt>Work persistence</dt>
<dd><%= @presenter.inspect_work.storage %></dd>

<dt>Result of to_solr</dt>
<dd><%= @presenter.inspect_work.solr %></dd>
</dl>
2 changes: 2 additions & 0 deletions config/locales/curation_concerns.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ en:
submit:
sipity_workflow_responsibility:
create: "Add"
inspect_work:
link_text: 'Inspect Work'
simple_form:
required:
html: '<span class="label label-info required-tag">required</span>'
Expand Down
1 change: 1 addition & 0 deletions lib/curation_concerns/rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def curation_concerns_basic_routes(&block)
namespaced_resources curation_concern_name, only: [] do
member do
get :file_manager
get :inspect_work
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,13 @@
expect(assigns(:presenter)).not_to be_blank
end
end

describe '#inspect_work' do
let(:work) { create(:private_generic_work, user: user) }
it "is successful" do
get :inspect_work, params: { id: work.id }
expect(response).to be_success
expect(assigns(:presenter)).not_to be_blank
end
end
end
9 changes: 9 additions & 0 deletions spec/presenters/curation_concerns/work_show_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@
end
end

context "with inspect_work" do
let(:user) { create(:user) }
let(:ability) { Ability.new(user) }
describe "#inspect_work" do
subject { presenter.inspect_work }
it { is_expected.to be_kind_of CurationConcerns::InspectWorkPresenter }
end
end

describe "graph export methods" do
let(:graph) do
RDF::Graph.new.tap do |g|
Expand Down
4 changes: 4 additions & 0 deletions spec/routing/route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
it 'routes to file_manager' do
expect(get: 'concern/generic_works/6/file_manager').to route_to(controller: 'curation_concerns/generic_works', action: 'file_manager', id: '6')
end

it 'routes to inspect_work' do
expect(get: 'concern/generic_works/6/inspect_work').to route_to(controller: 'curation_concerns/generic_works', action: 'inspect_work', id: '6')
end
end

describe 'Permissions' do
Expand Down

0 comments on commit 258f58e

Please sign in to comment.