-
Notifications
You must be signed in to change notification settings - Fork 5
Migrate org groups (hr_group -> admin_group, primary_group -> member_group) #1275
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
Open
simensandhaug
wants to merge
24
commits into
main
Choose a base branch
from
feat/migrate-org-group
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c6cf298
change hr_group and primary_group to admin_group and member_group in …
simensandhaug d800ba4
update group constants
simensandhaug 5faef25
change instances of hr_group and primary_group
simensandhaug 1d6e42b
fix query error
simensandhaug aa5c147
write custom migration
simensandhaug ad93482
revert changes to previous migrations
simensandhaug 22a5b20
revert changes to previous migrations
simensandhaug 1eef979
revert changes to previous migrations
simensandhaug de5d3d7
move custom migrations to more appropriate folder
simensandhaug 3733a79
merge migrations due to conflicts
simensandhaug ccd26d8
remove manage_organization permission from organizations/signals.py
simensandhaug bb000da
uncomment manage_organization permission in organizations/models.py
simensandhaug 008dfdb
remove autogenerated yarn.lock file
simensandhaug 188b95f
quality of life improvement for admin-panel, more easily readable wit…
simensandhaug 2cde7d2
Admin-panel improvements and update signal and migration to be more d…
simensandhaug 30d6ad4
update migration
simensandhaug fe30038
fix naming error
simensandhaug 6556ecf
fix typing error
simensandhaug 1f8b106
Update backend/apps/organizations/signals.py
simensandhaug a230e7b
Update backend/apps/organizations/signals.py
simensandhaug a6bc2b3
fix bug when referencing group.uuid
simensandhaug 0c5e871
Merge branch 'main' into feat/migrate-org-group
simensandhaug 3f005d2
Merge branch 'main' into feat/migrate-org-group
simensandhaug 6a8a60e
fix black linting
simensandhaug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
backend/apps/organizations/migrations/0034_alter_organization_options.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Generated by Django 3.2.16 on 2022-11-21 20:19 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("organizations", "0033_merge_0031_auto_20210909_1813_0032_auto_20210824_1457"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterModelOptions( | ||
| name="organization", | ||
| options={"permissions": [("manage_organization", "Can manage organizations, used for admins")]}, | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
backend/apps/permissions/migrations/0034_auto_20221114_1854.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Generated by Django 3.2.16 on 2022-11-14 17:54 | ||
|
|
||
| from django.db import migrations | ||
| from apps.permissions.constants import ADMIN_GROUP_TYPE, MEMBER_GROUP_TYPE | ||
|
|
||
|
|
||
| def migrate_org_groups(apps, schema_editor): | ||
| ResponsibleGroup = apps.get_model("permissions", "ResponsibleGroup") | ||
| for responsible_group in ResponsibleGroup.objects.all(): | ||
| if responsible_group.name == "HR": | ||
| # ResponsibleGroup names format is "Organization:Type" (e.g. "Organization:ADMIN") | ||
| # Type is either "ADMIN" or "MEMBER" | ||
| # ResponsibleGroup has a group field which is a django.contrib.auth.models.Group with outdated names | ||
| # Change the Type in group name to "ADMIN" or "MEMBER" depending on the ResponsibleGroup name (e.g. "Organization:HR:uuid" -> "Organization:ADMIN:uuid") | ||
| # Change ResponsibleGroup.group_type from "HR" or "PRIMARY" to "ADMIN" or "MEMBER" | ||
| responsible_group.name = f"{responsible_group.organization.name}:{ADMIN_GROUP_TYPE}" | ||
| responsible_group.group.name = ( | ||
| f"{responsible_group.organization.name}:{ADMIN_GROUP_TYPE}:git{responsible_group.group.uuid}" | ||
|
simensandhaug marked this conversation as resolved.
Outdated
|
||
| ) | ||
| responsible_group.group_type = ADMIN_GROUP_TYPE | ||
| responsible_group.save() | ||
| if responsible_group.name == "Medlem": | ||
| responsible_group.name = f"{responsible_group.organization.name}:{MEMBER_GROUP_TYPE}" | ||
| responsible_group.group.name = ( | ||
| f"{responsible_group.organization.name}:{MEMBER_GROUP_TYPE}:{responsible_group.group.uuid}" | ||
|
simensandhaug marked this conversation as resolved.
Outdated
|
||
| ) | ||
| responsible_group.group_type = MEMBER_GROUP_TYPE | ||
| responsible_group.save() | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("organizations", "0033_merge_0031_auto_20210909_1813_0032_auto_20210824_1457"), | ||
| ] | ||
|
|
||
| operations = [migrations.RunPython(migrate_org_groups)] | ||
13 changes: 13 additions & 0 deletions
13
backend/apps/permissions/migrations/0035_merge_20221117_1825.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Generated by Django 3.2.16 on 2022-11-17 17:25 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("permissions", "0011_merge_0004_auto_20210824_2126_0010_auto_20210824_1546"), | ||
| ("permissions", "0034_auto_20221114_1854"), | ||
| ] | ||
|
|
||
| operations = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.