Assigning a person to review a submission based on properties of the work. And you don't need multiple admin sets to do this.
Two primary concepts of the workflow in Hyrax 2.0:
- Permissions are assigned at two levels:
- Sipity::WorkflowResponsibility - A person has permissions to all things using this workflow
- Sipity::EntitySpecificResponsibility - A person has permissions to only the work/entity
- Sipity::Method - Something we "call" when we take a Sipity::Action.
- Hyrax::Workflow::PermissionGenerator
You'll need to understand the JSON workflow schema. See the [default workflow][template_workflows] of the method called when a user deposits a work: One method object, Hyrax::Workflow::GrantEditToDepositor, grants the user depositing rights for the deposit worked (eg. Sipity::EntitySpecificResponsibility).
You'll need to modify the workflow (an exercise left up to the reader) to include a method for the appropriate action.
Then create (and test) your method object.
module Hyrax::Workflow::AssignReviewerByDepartment
def self.call(target:, **)
reviewer = find_reviewer_for(department: target.department)
# This assigns database permissions, but does not grant permissions on the Fedora object.
Hyrax::Workflow::PermissionGenerator.call(entity: target, agent: reviewer, role: 'Reviewer')
# Do you want to update the Fedora object? Then you'll need to make adjustments.
end
def self.find_reviewer_for(department:)
# You do the work
end
end
# Make sure to test that your method conforms to the Hyrax workflow method interface
RSpec.describe Hyrax::Workflow::AssignReviewerByDepartment do
let(:workflow_method) { described_class }
it_behaves_like "a Hyrax workflow method"
end