Skip to content

Commit

Permalink
refactor embargo controllers to deduplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
tamsin johnson committed Aug 30, 2022
1 parent abb2b47 commit e307538
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,5 @@ def embargo_history(concern)
concern.try(:embargo_history) ||
concern.try(:embargo)&.embargo_history
end

def work_has_file_set_members?(work)
case work
when Valkyrie::Resource
Hyrax.custom_queries.find_child_file_set_ids(resource: work).any?
else
work.file_sets.present?
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def index
def destroy
Hyrax::Actors::LeaseActor.new(curation_concern).destroy
flash[:notice] = lease_history(curation_concern)&.last
if curation_concern.work? && curation_concern.file_sets.present?
if curation_concern.work? && work_has_file_set_members?(curation_concern)
redirect_to confirm_permission_path
else
redirect_to edit_lease_path
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/concerns/hyrax/manages_embargoes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,16 @@ def deny_access(exception)
end

def edit; end

private

def work_has_file_set_members?(work)
case work
when Valkyrie::Resource
Hyrax.custom_queries.find_child_file_set_ids(resource: work).any?
else
work.file_sets.present?
end
end
end
end

0 comments on commit e307538

Please sign in to comment.