-
Notifications
You must be signed in to change notification settings - Fork 5
Fix display behavior of metadata-only collections #480
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally looks good to me 👍 , though I defer to @lsitu for review on the various use cases, since I know you all have been working closely on this together.
Thanks @mcritchlow for reviewing. I forgot to submit other tests for search results. I just submitted them now. |
Fix display behavior for simple metadata-only object Remove un-used code Code cleanup Add tests for complex object Remove debug message Add tests for metadata-only object search Add tests for metadata-only public collection
274fce4
to
42175f3
Compare
lib/dams/controller_helper.rb
Outdated
@@ -903,6 +903,16 @@ def metadata_display?(data) | |||
data.any? { |t| t.include?('localDisplay') || t.include?('metadataDisplay') } | |||
end | |||
|
|||
def local_user_public_col?(document) | |||
return false unless !current_user.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/NegatedIf: Favor if over unless for negative conditions.
@ucsdlib/developers - The code has been updated and more tests have been added. Please review. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VivianChu It looks good. Just a few questions regarding ability check and access control to see whether there are some gaps there or not.
app/helpers/dams_objects_helper.rb
Outdated
@@ -788,7 +788,7 @@ def grabRestrictedText(data) | |||
def grab_access_text(document) | |||
out = [] | |||
data = rights_data document | |||
return nil unless metadata_display?(data) && cannot?(:read, document) | |||
return nil unless metadata_display?(data) && (current_user.nil? || local_user_public_col?(@document)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seems like using ability check should be more efficient and reliable here. I think if ability check is an issue, then we need to fix it in the access control level since it's really a matter to control object access.
What issue do you see with ability check cannot?(:read, document)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsitu - I already tried different ability check including cannot?(:read, document) for all type of users and they all return false. I couldn't use it to check for local or public user access local or public collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsitu - here are my test results to print out that ability check
local user - public collection : cannot? read - returns false
local user - local collection : cannot? read - returns false
public user - local collection : cannot? read - returns false
public user - public collection : cannot? read - returns false
I need a check for local user to access public collection with metadatadisplay object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsitu - You can try that condition for this test https://github.com/ucsdlib/damspas/pull/480/files#diff-bff6a4c6341ffbdd45f5cabab7685905R1037 and https://github.com/ucsdlib/damspas/pull/480/files#diff-bff6a4c6341ffbdd45f5cabab7685905R1121 Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VivianChu But either rspec or manual tests seems to be correct for localDisplay objects. So I am wondering whether there is an issue with setting up the test as what I'd seen before. Let me run your tests to see how it goes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VivianChu I see the problem. Your test at https://github.com/ucsdlib/damspas/pull/480/files#diff-bff6a4c6341ffbdd45f5cabab7685905R1037 is failed with ability check cannot?(:read, document)
because the object you setup for the test is a public object (copyright_attributes: [{status: 'Public domain'}]
: https://github.com/ucsdlib/damspas/pull/480/files#diff-bff6a4c6341ffbdd45f5cabab7685905R997). With the rules we'd setup in the past for access control, this is always a public object with no access control overriding. I don't know whether we'll have such a case in the future or not, but we may need a ticket to fix it at the access control level if this will become a real case. For now, I think you can change it to something like copyright_attributes: [{status: 'Unknown'}]
. In this case, access override will take it's role to override it for metadataDisplay and your tests for public metadata-only accesses will pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsitu - I'll update it to use other copyright_attributes "Under copyright" and change it to use cannot? read. Thanks
@@ -15,7 +15,7 @@ | |||
</div> | |||
</div> | |||
<% end %> | |||
<% access_notice = grab_access_text(@document) if cannot? :update, @document %> | |||
<% access_notice = grab_access_text(@document) if ( current_user.nil? || local_user_public_col?(@document)) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try to use ability check cannot? :read, @document
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that before and it failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsitu - You can try again in your local to see if the tests pass for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VivianChu I think setup the test object with copyright_attributes: [{status: 'Unknown'}]
will fix the puzzle. See my comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsitu - I tried both copyright_attributes: [{status: 'Under copyright.'}] and copyright_attributes: [{status: 'Unknown'}] and the test passed.
@@ -8,7 +8,9 @@ | |||
</div> | |||
</div> | |||
<% end %> | |||
<% if cannot? :update, @document then %> | |||
|
|||
<% if current_user.nil? || local_user_public_col?(@document) then %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -30,7 +30,7 @@ | |||
<div class="simple-object"></div> | |||
<% end %> | |||
<%# END RESTRICTED NOTICE %> | |||
<% if cannot? :update, @document then %> | |||
<% if current_user.nil? || local_user_public_col?(@document) then %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -320,7 +320,7 @@ def collection_search | |||
|
|||
def metadata_only_collections | |||
meta_colls = [] | |||
params = { q: 'visibility_tesim:local', fq: 'type_tesim:Collection' } | |||
params = { q: 'visibility_tesim:local OR visibility_tesim:public', fq: 'type_tesim:Collection' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like adding OR visibility_tesim:public
could bring up most of the collections if not all, which is close to 200 now. Is there a way to avoid scooping the public collections up or not? Just curios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsitu - let me try to filter the result. It's because they also want the support for public collection with metadataDisplay object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsitu - I updated it to use sub-query. Could you review it? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VivianChu LGTM 👍
@VivianChu Have a question for your updates - In the case that a record have both “dams:note => Culturally sensitive…”(or “dams:note =>Embargoed content”) AND “dams:otherRights => metadataDisplay” in the record(for example bb60078423, bb3789396) , Which text display would take the priority in the curator viewer? |
@hweng - I don't know. Let ask Gabriela. |
@VivianChu The current behavior on production is that the Culturally sensitive or Embargoed content would take the priority in the curator viewer. But not sure about after your updates, that why I asked. |
👍 |
@VivianChu @hweng For Culturally Sensitive or Embargo w/metadata-only visibility, curators will never see the banners when logged in. Only non-curators will see the relevant banners. |
@gamontoya Get it, Thanks! |
👍 |
Thanks everyone for reviewing and @hweng for merging. |
Fixes #466
Local Checklist
master
branch?What does this PR do?
Fix display behavior for both simple and complex metadata-only objects.
Also fix the search results generic icon for the metadata-only objects in public collections.
Why are we doing this? Any context of related work?
Currently on staging, these collections and objects are not behaving as expected. If I am on campus, I am seeing metadata-only behavior.
References #466
@ucsdlib/developers - please review