-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add permission for manage segments overrides (#2919)
- Loading branch information
Showing
16 changed files
with
350 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
55 changes: 55 additions & 0 deletions
55
api/environments/permissions/migrations/0008_add_manage_segment_overrides_permission.py
This file contains 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,55 @@ | ||
# Generated by Django 3.2.20 on 2023-11-01 19:54 | ||
|
||
from django.db import migrations | ||
from environments.permissions.constants import MANAGE_SEGMENT_OVERRIDES, UPDATE_FEATURE_STATE | ||
from core.migration_helpers import create_new_environment_permissions | ||
|
||
from permissions.models import ENVIRONMENT_PERMISSION_TYPE | ||
|
||
def add_manage_segment_overrides_permission(apps, schema_editor): | ||
PermissionModel = apps.get_model("permissions", "PermissionModel") | ||
UserEnvironmentPermission = apps.get_model( | ||
"environment_permissions", | ||
"UserEnvironmentPermission", | ||
) | ||
UserPermissionGroupEnvironmentPermission = apps.get_model( | ||
"environment_permissions", | ||
"UserPermissionGroupEnvironmentPermission", | ||
) | ||
manage_segment_overrides_permission, _ = PermissionModel.objects.get_or_create( | ||
key=MANAGE_SEGMENT_OVERRIDES, | ||
description="Permission to manage segment overrides in the given environment", | ||
type=ENVIRONMENT_PERMISSION_TYPE, | ||
) | ||
|
||
# Add MANAGE_SEGMENT_OVERRIDES to existing UPDATE_FEATURE_STATE holders | ||
create_new_environment_permissions( | ||
UPDATE_FEATURE_STATE, | ||
UserEnvironmentPermission, | ||
"userenvironmentpermission", | ||
[manage_segment_overrides_permission], | ||
) | ||
create_new_environment_permissions( | ||
UPDATE_FEATURE_STATE, | ||
UserPermissionGroupEnvironmentPermission, | ||
"userpermissiongroupenvironmentpermission", | ||
[manage_segment_overrides_permission], | ||
) | ||
|
||
|
||
def remove_manage_segment_overrides_permission(apps, schema_editor): | ||
PermissionModel = apps.get_model("permissions", "PermissionModel") | ||
PermissionModel.objects.filter(key=MANAGE_SEGMENT_OVERRIDES).delete() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('environment_permissions', '0007_add_unique_permission_constraint'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
add_manage_segment_overrides_permission, | ||
reverse_code=remove_manage_segment_overrides_permission, | ||
) | ||
] |
This file contains 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 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 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 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.
716f6a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-git-main-flagsmith.vercel.app
docs.bullet-train.io
docs-flagsmith.vercel.app
docs.flagsmith.com
716f6a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-preview-flagsmith.vercel.app
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
flagsmith-frontend-production-native.vercel.app
716f6a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
staging.flagsmith.com
flagsmith-staging-frontend.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app