-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Orphan Document scenario for Document Collection
Document Collection Groups assume that documents added to the document groups always have a latest_edition attached to it since users are only allowed to search for and add published documents to the group. However, since there is behaviour to unpublish and delete the edition, the document is left orphaned, which is currently causing server errors for users who have previously added this document to their Document Collection Group. Fix is to render the unavailable document so that the user would know to remove this orphaned document relationship from their document collection group. Co-Authored-By: Nikin Nagewadia <[email protected]>
- Loading branch information
Showing
6 changed files
with
147 additions
and
57 deletions.
There are no files selected for viewing
24 changes: 15 additions & 9 deletions
24
app/helpers/admin/document_collection_group_memberships_helper.rb
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 |
---|---|---|
@@ -1,17 +1,23 @@ | ||
module Admin::DocumentCollectionGroupMembershipsHelper | ||
def document_collection_group_member_title(membership) | ||
if membership.non_whitehall_link | ||
membership.non_whitehall_link.title | ||
else | ||
membership.document.latest_edition.title | ||
end | ||
return membership.non_whitehall_link.title if membership.non_whitehall_link | ||
|
||
membership.document.latest_edition.title | ||
end | ||
|
||
def document_collection_group_member_url(membership) | ||
if membership.non_whitehall_link | ||
Plek.website_root + membership.non_whitehall_link.base_path | ||
else | ||
membership.document.latest_edition.public_url | ||
return Plek.website_root + membership.non_whitehall_link.base_path if membership.non_whitehall_link | ||
|
||
membership.document.latest_edition.public_url | ||
end | ||
|
||
def document_collection_group_member_unavailable?(membership) | ||
!membership.non_whitehall_link && !membership.document&.latest_edition | ||
end | ||
|
||
def unavailable_document_count(memberships) | ||
memberships.count do |membership| | ||
document_collection_group_member_unavailable?(membership) | ||
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