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

Properly set admin_imported flag at import and deletion. #11254

Conversation

rtibbles
Copy link
Member

@rtibbles rtibbles commented Sep 15, 2023

Summary

  • Regenerates the SQLAlchemy reflection of the current channel schema as it had not been done previously.
  • Removes the force_delete flag from content request handling deletions, as that could force deletions of admin imported resources to occur
  • Updates the annotation logic to allow updating the admin_imported flag - uses a coalesce and OR function to ensure that the null Boolean value gets set to False or True (or left as is if None).
  • Updates all resource import managers to default to setting admin_imported to True, except for the individual resource import class, which sets it to False by default
  • Adds tests for the annotation behaviours
  • Updates the node invisibility marking to allow explicit setting of admin_imported to False
  • Adds an additional flag to the deletecontent command to disable this behaviour, but by default will always do this (which should maintain parity with the current 0.15 behaviour for the management command)
  • Updates the use of the deletecontent command in the content request handling to not clear admin_imported flags
  • Adds persistence of admin imported flag across channel upgrades - unfortunately, adding a test for this was challenging, because of the structure of our importchannel command, but the logic is very straight forward.

References

Fixes #11225

Reviewer guidance

This should cover all cases, including loading a full channel database import, after partial imports have happened - the only different will be that admin_imported will be None rather than False - but this is equivalent in how we are using it and should be workable. I think this may not cover where a full channel import has happened previously, then admin_imported is set to False for some nodes, while also being available - but then the channel metadata is upgraded.

admin_imported being set to True should persist across channel upgrades due to our existing upgrade processes that reannotate after the upgrade has happened.


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@rtibbles rtibbles added the TODO: needs review Waiting for review label Sep 15, 2023
@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: medium labels Sep 15, 2023
@rtibbles rtibbles changed the title Im an admin import and im okay Properly set admin_imported flag at import and deletion. Sep 15, 2023
…al requests.

As could remove other resources that have not been flagged for removal.
Do previously omitted update to current content schema reflection.
@rtibbles rtibbles force-pushed the im_an_admin_import_and_im_okay branch from 10e8651 to a806b8a Compare September 16, 2023 00:23
@rtibbles rtibbles force-pushed the im_an_admin_import_and_im_okay branch from a806b8a to eb2da96 Compare September 17, 2023 01:17
@rtibbles rtibbles marked this pull request as draft September 18, 2023 00:32
Copy link
Member

@jredrejo jredrejo left a comment

Choose a reason for hiding this comment

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

Code LGTM. Made some manual tests that were ok

@rtibbles rtibbles marked this pull request as ready for review September 26, 2023 01:27
@rtibbles rtibbles merged commit 9a3b44e into learningequality:release-v0.16.x Sep 26, 2023
@rtibbles rtibbles deleted the im_an_admin_import_and_im_okay branch September 26, 2023 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... SIZE: medium TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically synced content should have admin_imported=False
3 participants