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

Add rake task to assign access permissions for an organisation #2422

Merged
merged 6 commits into from
Nov 27, 2024

Conversation

Tetrino
Copy link
Contributor

@Tetrino Tetrino commented Nov 18, 2024

Two tasks are added that allow us to:

  • Assign permissions on a case by case basis for specific artefacts
  • Assign an org permission to a group of artefacts from a CSV file containing rows of URLs

There is no easy way to find the OrgID from an org name so OrgID must be provided by us when using it in the rake tasks.

https://trello.com/c/60RkKgwP/478-rake-task-to-set-owning-org-for-hmrc-content-mainstream

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Follow these steps if you are doing a Rails upgrade.

@Tetrino Tetrino force-pushed the org-permissions-rake-task branch 3 times, most recently from 0884ceb to 8e71281 Compare November 18, 2024 08:44
Four tasks are added that allow us to:

- Assign and remove permissions on a case by case basis for specific artefacts
- Remove all permission flags from an artefact, essentially resetting it to open permission
- Assign an org permission to a group of artefacts from a CSV file containing rows of URLs

There is no easy way to find the OrgID from an org name so OrgID must be provided by us
when using it in the rake tasks.
@Tetrino Tetrino force-pushed the org-permissions-rake-task branch from 8e71281 to d1e2825 Compare November 18, 2024 08:47
@baisa baisa force-pushed the org-permissions-rake-task branch 6 times, most recently from caddfeb to b21951e Compare November 20, 2024 08:02
@baisa baisa force-pushed the org-permissions-rake-task branch from b21951e to 24337a4 Compare November 21, 2024 09:04
@ellohez ellohez force-pushed the org-permissions-rake-task branch 2 times, most recently from 3f1505e to d9be641 Compare November 21, 2024 13:37
@ellohez ellohez marked this pull request as ready for review November 21, 2024 14:38
@ellohez ellohez force-pushed the org-permissions-rake-task branch from 2bd86e8 to df8c83c Compare November 21, 2024 15:26
- Logging allows us to gather a list of documents that cannot be found
- Failure to find is typically because the path/slug has changed.
@ellohez ellohez force-pushed the org-permissions-rake-task branch from df8c83c to 26a3320 Compare November 21, 2024 15:29
Copy link
Contributor

@mtaylorgds mtaylorgds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments.

if document.nil?
message = "Document ID #{args[:document_content_id]} not found, no permissions changed."
elsif document.latest_edition.owning_org_content_ids.include?(args[:org_content_id])
message = "Organisation already has permission to access the document with ID - #{document.id}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth capturing the org ID in the various log messages?

Copy link
Contributor

@ellohez ellohez Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! I have added this to the start of the log file - see line 29

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this rake task can be called independently of the bulk one, I think it might still be a good idea to include the org ID in the log messages here.

lib/tasks/access_and_permissions.rake Outdated Show resolved Hide resolved
lib/tasks/access_and_permissions.rake Show resolved Hide resolved
lib/tasks/access_and_permissions.rake Outdated Show resolved Hide resolved
@ellohez ellohez force-pushed the org-permissions-rake-task branch 2 times, most recently from e56afad to 9e6bdb8 Compare November 25, 2024 09:49
@ellohez
Copy link
Contributor

ellohez commented Nov 25, 2024

Now working on Integration.

Copy link
Contributor

@mtaylorgds mtaylorgds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment.

if document.nil?
message = "Document ID #{args[:document_content_id]} not found, no permissions changed."
elsif document.latest_edition.owning_org_content_ids.include?(args[:org_content_id])
message = "Organisation already has permission to access the document with ID - #{document.id}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this rake task can be called independently of the bulk one, I think it might still be a good idea to include the org ID in the log messages here.

lib/tasks/access_and_permissions.rake Show resolved Hide resolved
@ellohez ellohez force-pushed the org-permissions-rake-task branch from 9e6bdb8 to 37030c5 Compare November 26, 2024 11:42
@ellohez ellohez force-pushed the org-permissions-rake-task branch from 37030c5 to 06a376e Compare November 26, 2024 12:19
@ellohez ellohez requested a review from mtaylorgds November 26, 2024 14:57
@ellohez ellohez merged commit 3dd049a into main Nov 27, 2024
12 checks passed
@ellohez ellohez deleted the org-permissions-rake-task branch November 27, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants