Code for Permission Templates
Table of Contents
Where is the code for permission templates?
- https://github.com/samvera/hyrax/blob/master/app/models/hyrax/permission_template.rb
- https://github.com/samvera/hyrax/blob/master/app/models/hyrax/permission_template_access.rb
- https://github.com/samvera/hyrax/blob/master/app/controllers/hyrax/admin/permission_templates_controller.rb
- https://github.com/samvera/hyrax/blob/master/app/controllers/hyrax/admin/permission_template_accesses_controller.rb
- https://github.com/samvera/hyrax/blob/master/app/forms/hyrax/forms/permission_template_form.rb
- https://github.com/samvera/hyrax/blob/master/db/migrate/20161021175854_create_permission_template.rb
- https://github.com/samvera/hyrax/blob/master/db/migrate/20161021180154_create_permission_template_access.rb
- https://github.com/samvera/hyrax/blob/master/db/migrate/20161116222307_add_release_to_permission_templates.rb
What information do they hold?
I'm guessing it is this kind of information...
- participants for an admin set
- visibility template for a work created in an admin set
- selected workflow to use for works created in an admin set
You can get a good sense of what PTs hold by looking at the PTForm;Ā https://github.com/samvera/hyrax/blob/master/app/forms/hyrax/forms/permission_template_form.rb
Permissions templates have a 1-1 relationship to admin sets. Ā Admin sets are the Fedora portion of the implementation, and Permission templates are the database portion.Ā
- Permission templates hold the visibility information for the admin set (visibility, release date, and release period). There is a lot of behind-the-scenes logic using these in determining the embargo logic (see pull requestĀ https://github.com/samvera/hyrax/pull/490) which would be much clearer if the information were explicitly stored in the permission template.
- Via the child table "Permission template accesses", they also store each of the participants (either user or group) which has been granted access via the permission template (the agent id, agent type, and access for the permission template)
- Sipity::Workflows are stamped with the active permission template id.Ā
When are they created?
I'm guessing that it is when the admin set is created.Ā And possibly when a work is created to hold participant information?
Yes, permission templates are created by the AdminSetCreateService:Ā https://github.com/samvera/hyrax/blob/master/app/services/hyrax/admin_set_create_service.rb#L62
They can also be created by the DefaultAdminSetActor:Ā https://github.com/samvera/hyrax/blob/master/app/actors/hyrax/actors/default_admin_set_actor.rb#L44
When are they used?
I'm guessing when a work is created, the participants are assigned access, the visibility of the work is set based on the visibility template, and the workflow is attached to the work.
I believe that is correct.