-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Namespace vieset_name in AccessPolicy
To avoid naming conflicts with similarly named viewsets in plugins, a scoping by the plugin app_id is needed. fixes #7845 https://pulp.plan.io/issues/7845
- Loading branch information
Showing
8 changed files
with
56 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Properly namespaced the `viewset_name` in `AccessPolicy` to avoid naming conflicts in plugins. |
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,10 @@ | ||
Using the ViewSet's classname to identify its AccessPolicy has been deprecated and is slated for removal in 3.10. | ||
Instead the urlpattern is supposed to be used. | ||
|
||
Plugins with existing AccessPolicies should add a data migration to rename their AccessPolicies: | ||
|
||
:: | ||
access_policy = AccessPolicy.get(viewset_name="MyViewSet") | ||
access_policy.viewset_name = "objectclass/myplugin/myclass" | ||
access_policy.save() | ||
|
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
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,28 @@ | ||
# Generated by Django 2.2.17 on 2020-11-18 09:41 | ||
|
||
from django.db import migrations | ||
|
||
from pulpcore.app.models import AccessPolicy | ||
|
||
|
||
def namespace_access_policies_up(apps, schema_editor): | ||
task_policy = AccessPolicy.objects.get(viewset_name="TaskViewSet") | ||
task_policy.viewset_name = "tasks" | ||
task_policy.save() | ||
|
||
|
||
def namespace_access_policies_down(apps, schema_editor): | ||
AccessPolicy.objects.get(viewset_name="tasks").delete() | ||
task_policy.viewset_name = "TaskViewSet" | ||
task_policy.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0049_add_file_field_to_uploadchunk'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(namespace_access_policies_up, reverse_code=namespace_access_policies_down), | ||
] |
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