-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add MANAGE_TAGS permission (#4628)
- Loading branch information
1 parent
46630a2
commit 566520f
Showing
5 changed files
with
62 additions
and
9 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
api/permissions/migrations/0010_add_manage_tags_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,32 @@ | ||
# Generated by Django 4.2.15 on 2024-09-13 16:18 | ||
from django.apps.registry import Apps | ||
from django.db import migrations | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
|
||
from permissions.models import PROJECT_PERMISSION_TYPE | ||
from projects.permissions import MANAGE_TAGS | ||
|
||
|
||
def add_manage_tags_permission(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: | ||
permission_model_class = apps.get_model("permissions", "permissionmodel") | ||
permission_model_class.objects.get_or_create( | ||
key=MANAGE_TAGS, | ||
description="Allows the user to manage tags in the given project.", | ||
type=PROJECT_PERMISSION_TYPE, | ||
) | ||
|
||
|
||
def reverse(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: # pragma: no cover | ||
permission_model_class = apps.get_model("permissions", "permissionmodel") | ||
permission_model_class.objects.filter(key=MANAGE_TAGS).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("permissions", "0009_move_view_audit_log_permission"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(add_manage_tags_permission, reverse_code=reverse), | ||
] |
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