-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5810 from samvera/valkyrie-embargo-controller
get a minimal passing EmbargoController for Valkyrie
- Loading branch information
Showing
19 changed files
with
347 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hyrax | ||
module Forms | ||
## | ||
# Represents an embargo for edit through a work. That is, this form can | ||
# be used to wrap a Work in order to capture state changes related only to | ||
# its embargo, ignoring the work's other fields. | ||
# | ||
# @note this supports the edit functionality of | ||
# +EmbargoesControllerBehavior+. | ||
class WorkEmbargoForm < Hyrax::ChangeSet | ||
property :embargo, form: Hyrax::Forms::Embargo, populator: :embargo_populator, prepopulator: :embargo_populator | ||
property :embargo_release_date, virtual: true, prepopulator: ->(_opts) { self.embargo_release_date = model.embargo&.embargo_release_date } | ||
property :visibility_after_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_after_embargo = model.embargo&.visibility_after_embargo } | ||
property :visibility_during_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_during_embargo = model.embargo&.visibility_during_embargo } | ||
|
||
def embargo_populator(**) | ||
self.embargo = Hyrax::EmbargoManager.embargo_for(resource: model) | ||
end | ||
|
||
## | ||
# @return [String] | ||
def human_readable_type | ||
model.to_model.human_readable_type | ||
end | ||
|
||
## | ||
# @return [ActiveModel::Name] | ||
def model_name | ||
model.to_model.model_name | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hyrax | ||
module Forms | ||
## | ||
# Represents a lease for edit through a work. That is, this form can | ||
# be used to wrap a Work in order to capture state changes related only to | ||
# its lease, ignoring the work's other fields. | ||
# | ||
# @note this supports the edit functionality of | ||
# +LeasesControllerBehavior+. | ||
class WorkLeaseForm < Hyrax::ChangeSet | ||
property :lease, form: Hyrax::Forms::Lease, populator: :lease_populator, prepopulator: :lease_populator | ||
property :lease_expiration_date, virtual: true, prepopulator: ->(_opts) { self.lease_expiration_date = model.lease&.lease_expiration_date } | ||
property :visibility_after_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_after_lease = model.lease&.visibility_after_lease } | ||
property :visibility_during_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_during_lease = model.lease&.visibility_during_lease } | ||
|
||
def lease_populator(**) | ||
self.lease = Hyrax::LeaseManager.lease_for(resource: model) | ||
end | ||
|
||
## | ||
# @return [String] | ||
def human_readable_type | ||
model.to_model.human_readable_type | ||
end | ||
|
||
## | ||
# @return [ActiveModel::Name] | ||
def model_name | ||
model.to_model.model_name | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.