Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create presave validation hook for field_member_of and field_access_terms #108

Closed
bseeger opened this issue Apr 7, 2021 · 7 comments
Closed

Comments

@bseeger
Copy link

bseeger commented Apr 7, 2021

We should create a pre-save validation hook (maybe in islandora defaults) to prevent a user from putting values they don't have access to in those particular fields.

This would prevent a user from putting an object in a collection they don't have edit access to. This could help solve part of the problem outlined in #107. If we had a presave hook, it wouldn't matter so much what showed up in the UI, as this hook would catch any invalid values for that user.
This is also key to helping prevent the migration ingest from putting items in collections it shouldn't.

To be clear, if we have time to do one thing, this has a higher benefit then #107 as it will provide validation before saving the node. It will cover both the UI workflow and Ingest workflow paths.

@birkland
Copy link

birkland commented Jun 9, 2021

It is unclear if this is a prerequisite for #114 or not.

@jordandukart
Copy link

jordandukart commented Jun 30, 2021

So proof of concepted this quickly to do what was discussed as a MVP. Ran it past @bseeger and it seems to meet the intent of what's being intended for the time being.

To distill it out down leveraging the workbench_access_entity_access check to ensure that the user ingesting has the correct access to reference an object. If not a constraint validation is thrown and the field is targeted with an error message. To note this would also throw an error if validate: true was used in the context of a migration.

In the below scenario two collections are made: "Collection A" and "Collection B". The "test" user is given access to ingest into "Collection B" only.

When attempting to ingest into "Collection A":

Screenshot 2021-06-30 at 16-59-26 Create Repository Item Default

Ingest into "Collection B" yields a new object.

Currently this code lives in the idc_ui_module but I'm unsure if this should be the permanent home for these types of customizations. @birkland can you confirm where you'd like these to live or if a new module should be created?

In regards to other work that distills out from this:

  • An EntityReferenceSelectionPlugin such that these options are never present in the UI at all (estimate: 3-4 hours).
  • A migrate plugin that ensures the user has access to a given entity (estimate: 3-4 hours).

@jordandukart
Copy link

As discussed on the iDC developer call I will go ahead and create a new module that will begin to contain more general hooks that aren't UI related.

@jordandukart
Copy link

jordandukart commented Jul 2, 2021

Fixed in jhu-idc/idc_defaults#1.

@jordandukart
Copy link

As discussed in Slack tests are required for the above so this issue isn't ready for review yet.

@jordandukart
Copy link

field_access_terms handled in jhu-idc/idc_defaults#4.

@birkland
Copy link

birkland commented Aug 3, 2021

All related PRs are merged, so this is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants