Skip to content

Instantly share code, notes, and snippets.

@jeremyf
Created November 8, 2017 20:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyf/57fa388e8625792e3971725cb902ca5f to your computer and use it in GitHub Desktop.
Save jeremyf/57fa388e8625792e3971725cb902ca5f to your computer and use it in GitHub Desktop.
Assigning a person to review a submission based on properties of the work

Goal

Assigning a person to review a submission based on properties of the work. And you don't need multiple admin sets to do this.

Whirlwind Workflow

Two primary concepts of the workflow in Hyrax 2.0:

  1. Permissions are assigned at two levels:
  2. Sipity::WorkflowResponsibility - A person has permissions to all things using this workflow
  3. Sipity::EntitySpecificResponsibility - A person has permissions to only the work/entity
  4. Sipity::Method - Something we "call" when we take a Sipity::Action.
  5. Hyrax::Workflow::PermissionGenerator

How to Do This

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment