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

Rename core developer (take 2) #4639

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Jongmassey
Copy link
Contributor

@Jongmassey Jongmassey commented Oct 2, 2024

fixes #4604

In order for us to successfully migrate from one role to another, we need to be able to remove the old role from the codebase.

Prior to this PR, there was no graceful handling of the situation where a user record in the db had roles whose path was no longer present in the codebase.

This change handles this situation more gracefully by creating a skeleton role type with that path (but no model associations or permissions) in such a way that these "legacy" roles round trip from the database.

This change includes the change of name of role in the codebase, this more graceful role parsing, and a migration to change the existing role records in the database. The migration also includes local fake role classes and as such is not coupled to the old CoreDeveloper or new StaffAreaAdministrator roles in the codebase.

@Jongmassey Jongmassey force-pushed the Jongmassey/CoreDeveloper-role-might-be-mis-named branch 2 times, most recently from 61d63b1 to 31f9050 Compare October 2, 2024 12:32
@Jongmassey Jongmassey changed the title Jongmassey/core developer role might be mis named Rename core developer (take 2) Oct 2, 2024
@Jongmassey Jongmassey force-pushed the Jongmassey/CoreDeveloper-role-might-be-mis-named branch 2 times, most recently from df093e2 to bd8f5a8 Compare October 2, 2024 17:17
@Jongmassey Jongmassey marked this pull request as draft October 2, 2024 17:17
@Jongmassey Jongmassey marked this pull request as draft October 2, 2024 17:17
@Jongmassey
Copy link
Contributor Author

I have tested locally this with a fresh dump of the prod database, running manage.py migrate then just run - I can log in as myself and access all the staff area

@Jongmassey Jongmassey force-pushed the Jongmassey/CoreDeveloper-role-might-be-mis-named branch 4 times, most recently from 9598117 to 9ca2b76 Compare October 4, 2024 09:03
@Jongmassey Jongmassey force-pushed the Jongmassey/CoreDeveloper-role-might-be-mis-named branch from 9ca2b76 to e9d04b2 Compare October 4, 2024 09:12
@mikerkelly
Copy link
Contributor

I think the non-docs commits should be squished before merging, as they're atomic, I think? You don't want to roll back or deploy any one individually. Re-name and references work together, you need to migrate if your DB has been either side of these commits.

@@ -0,0 +1,44 @@
# Generated by Django 5.1.1 on 2024-10-02 11:00
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is mostly hand-written and should have a docstring explaining why it exists, what the purpose and rationale are, and the approach taken. If anyone need to come back to where we are I think that will be very non-obvious.

@Jongmassey
Copy link
Contributor Author

@mikerkelly yes, will squash before merge - keeping them separate made it easier for me to iterate on reworking this.

@Jongmassey Jongmassey force-pushed the Jongmassey/CoreDeveloper-role-might-be-mis-named branch 3 times, most recently from 1c716e4 to 2af1d21 Compare October 4, 2024 13:31
@Jongmassey Jongmassey marked this pull request as ready for review October 4, 2024 13:31
@Jongmassey Jongmassey force-pushed the Jongmassey/CoreDeveloper-role-might-be-mis-named branch from 2af1d21 to 81cc5ed Compare October 4, 2024 13:35
Where a role path in the db is not found in the current codebase,
create a skeleton permissionless role instead of blowing up.

This means we can remove role names from the python code and legacy entries
in the db will no longer cause adverse effects.

This supports finding of the old roles in (for example) a migration, but leaves
these old unknown roles untouched unless they are explicitly acted on.
This role controls access to the Staff Area,
role holders might not necessarily be  developers, but admin staff.

Therefore, Staff Area Administrator was deemed to be a better fit for this role
Coupling of migrations to role classes (be the historic or current)
causes difficulties for future changes to role classes.

This migration therefore uses local classes which will match database
values created from the real role classes, and whose own corresponding
database values will parse to real role classes (if existing).
@Jongmassey Jongmassey force-pushed the Jongmassey/CoreDeveloper-role-might-be-mis-named branch from 81cc5ed to 81e4354 Compare October 4, 2024 13:44
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.

CoreDeveloper role might be mis-named
2 participants