Skip to content

Commit

Permalink
Merge pull request #302 from curationexperts/dark_state
Browse files Browse the repository at this point in the history
Dark state
  • Loading branch information
alexBLR committed Jun 9, 2017
2 parents 35bd74c + c7c0176 commit e7a3405
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .solr_wrapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Place any default configuration for solr_wrapper here
# port: 8983
version: 6.5.1
version: 6.6.0
instance_dir: tmp/solr-development
collection:
persist: true
Expand Down
10 changes: 10 additions & 0 deletions app/models/etd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ def set_defaults
self.degree_granting_institution = "http://id.loc.gov/vocabulary/organizations/geu"
end

def hidden?
return false unless hidden
true
end

# Boolean
property :hidden, predicate: "http://emory.edu/local/hidden", multiple: false do |index|
index.as :stored_searchable, :facetable
end

property :degree, predicate: "http://vivoweb.org/ontology/core#AcademicDegree" do |index|
index.as :stored_searchable, :facetable
end
Expand Down
19 changes: 19 additions & 0 deletions app/services/hyrax/workflow/hidden_notification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Hyrax
module Workflow
class HiddenNotification < AbstractNotification
private

def subject
'Deposit has been hidden'
end

def message
"#{title} (#{link_to work_id, document_path}) was hidden by #{user.user_key} #{comment}"
end

def users_to_notify
super << user
end
end
end
end
14 changes: 14 additions & 0 deletions app/services/hyrax/workflow/hide_object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Hyrax
module Workflow
##
# Mark an object hidden. It will never be displayed to the public, only
# visible to superusers and school approvers.
#
# @param target [#state] an instance of a model
module HideObject
def self.call(target:, **)
target.hidden = true
end
end
end
end
19 changes: 19 additions & 0 deletions app/services/hyrax/workflow/unhidden_notification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Hyrax
module Workflow
class UnhiddenNotification < AbstractNotification
private

def subject
'Deposit has been unhidden'
end

def message
"#{title} (#{link_to work_id, document_path}) was unhidden by #{user.user_key} #{comment}"
end

def users_to_notify
super << user
end
end
end
end
13 changes: 13 additions & 0 deletions app/services/hyrax/workflow/unhide_object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Hyrax
module Workflow
##
# Remove the hidden flag for an object
#
# @param target [#state] an instance of a model
module UnhideObject
def self.call(target:, **)
target.hidden = false
end
end
end
end
2 changes: 1 addition & 1 deletion config/solr_wrapper_test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#config/solr_wrapper_test.yml
version: 6.5.1
version: 6.6.0
port: 8985
instance_dir: tmp/solr-test
collection:
Expand Down
30 changes: 30 additions & 0 deletions config/workflows/laney_graduate_school.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,36 @@
"to": ["approving"]
}
]
}, {
"name": "hide",
"from_states": [
{ "names": ["pending_review", "pending_approval", "approved", "changes_required"], "roles": ["reviewing", "approving"] }
],
"notifications": [
{
"notification_type": "email",
"name": "Hyrax::Workflow::HiddenNotification",
"to": ["approving"]
}
],
"methods": [
"Hyrax::Workflow::HideObject"
]
}, {
"name": "unhide",
"from_states": [
{ "names": ["pending_review", "pending_approval", "approved", "changes_required"], "roles": ["reviewing", "approving"] }
],
"notifications": [
{
"notification_type": "email",
"name": "Hyrax::Workflow::UnhiddenNotification",
"to": ["approving"]
}
],
"methods": [
"Hyrax::Workflow::UnhideObject"
]
}
]
}
Expand Down
23 changes: 23 additions & 0 deletions spec/features/laney_workflow_etd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
expect(available_workflow_actions.include?("approve")).to eq false
expect(available_workflow_actions.include?("request_changes")).to eq false
expect(available_workflow_actions.include?("comment_only")).to eq false
expect(available_workflow_actions.include?("hide")).to eq false
expect(available_workflow_actions.include?("unhide")).to eq false

# Check notifications for depositing user
visit("/notifications?locale=en")
Expand All @@ -71,6 +73,8 @@
expect(available_workflow_actions.include?("approve")).to eq false # it can't be approved until after it has been marked as reviewed
expect(available_workflow_actions.include?("request_changes")).to eq true
expect(available_workflow_actions.include?("comment_only")).to eq true
expect(available_workflow_actions.include?("hide")).to eq true
expect(available_workflow_actions.include?("unhide")).to eq true

# Last superuser should have all workflow options available. (First superuser gets these by virtue of owning the admin sets.)
expect(w.superusers.count).to be > 1 # This test is meaningless if there is only one superuser
Expand All @@ -79,6 +83,8 @@
expect(available_workflow_actions.include?("approve")).to eq false # it can't be approved until after it has been marked as reviewed
expect(available_workflow_actions.include?("request_changes")).to eq true
expect(available_workflow_actions.include?("comment_only")).to eq true
expect(available_workflow_actions.include?("hide")).to eq true
expect(available_workflow_actions.include?("unhide")).to eq true

# The approving user marks the etd as reviewed
subject = Hyrax::WorkflowActionInfo.new(etd, approving_user)
Expand All @@ -96,9 +102,26 @@
Hyrax::Workflow::WorkflowActionService.run(subject: subject, action: sipity_workflow_action, comment: nil)
expect(etd.to_sipity_entity.reload.workflow_state_name).to eq "approved"

# The approving user hides the ETD
expect(etd.hidden?).to eq false
sipity_workflow_action = PowerConverter.convert_to_sipity_action("hide", scope: subject.entity.workflow) { nil }
Hyrax::Workflow::WorkflowActionService.run(subject: subject, action: sipity_workflow_action, comment: "hiding for reasons")
expect(etd.to_sipity_entity.reload.workflow_state_name).to eq "approved" # workflow state has not changed
expect(etd.hidden?).to eq true

# The approving user unhides the ETD
sipity_workflow_action = PowerConverter.convert_to_sipity_action("unhide", scope: subject.entity.workflow) { nil }
Hyrax::Workflow::WorkflowActionService.run(subject: subject, action: sipity_workflow_action, comment: "unhiding for reasons")
expect(etd.to_sipity_entity.reload.workflow_state_name).to eq "approved" # workflow state has not changed
expect(etd.hidden?).to eq false

# Check notifications for approving user
visit("/notifications?locale=en")
expect(page).to have_content "#{title} (#{etd.id}) was approved by"
expect(page).to have_content "#{title} (#{etd.id}) was hidden by"
expect(page).to have_content "hiding for reasons"
expect(page).to have_content "#{title} (#{etd.id}) was unhidden by"
expect(page).to have_content "unhiding for reasons"

# Check notifications for depositor again
logout
Expand Down
13 changes: 13 additions & 0 deletions spec/models/etd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
require 'rails_helper'

RSpec.describe Etd do
context "#hidden?" do
let(:etd) { FactoryGirl.create(:etd) }
context "with a new ETD" do
it "is not hidden when it is first created" do
expect(etd.hidden?).to eq false
end
it "can be set to true" do
etd.hidden = true
expect(etd.hidden?).to eq true
end
end
end

describe "#degree" do
subject { described_class.new }
let(:degree) { "Bachelor of Arts with Honors" }
Expand Down

0 comments on commit e7a3405

Please sign in to comment.