-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Theses not publishable with duplicate filenames
Why are these changes being introduced: * we cannot send theses to preservation with duplicate filenames * preservation is a step after publication, so doing this check before publication will ensure we don't publish things we can't preserve Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/ETD-648 How does this address that need: * Moves the baggable? logic to it's own module * Inlcudes that module in both SIP and Thesis models * Uses the unique_filenames? check as part of the thesis publication checks * Adds a visual display to the processor checklist to indicate if filenames are unique Document any side effects to this change: * There is no direct mechanism in the application to allow a processor to resolve duplicate filename issues
- Loading branch information
Showing
5 changed files
with
78 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Baggable | ||
# Before we try to bag anything, we need to check if it meets a few conditions. All published theses should have | ||
# at least one file attached, no duplicate filenames, a handle pointing to its DSpace record, and an accession number. | ||
def baggable_thesis?(thesis) | ||
return false unless thesis | ||
|
||
thesis.files.any? && thesis.dspace_handle.present? && unique_filenames?(thesis) && thesis.copyright.present? \ | ||
&& thesis.accession_number.present? | ||
end | ||
|
||
def unique_filenames?(thesis) | ||
!duplicate_filenames?(thesis) | ||
end | ||
|
||
def duplicate_filenames?(thesis) | ||
filenames = thesis.files.map { |f| f.filename.to_s } | ||
filenames.select { |f| filenames.count(f) > 1 }.uniq.any? | ||
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