mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-20 02:51:27 +00:00
[Update] 修正migrations
This commit is contained in:
@@ -3,18 +3,6 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def set_default_action_to_existing_perms(apps, schema_editor):
|
||||
from orgs.utils import set_to_root_org
|
||||
from ..models import Action
|
||||
set_to_root_org()
|
||||
perm_model = apps.get_model('perms', 'AssetPermission')
|
||||
db_alias = schema_editor.connection.alias
|
||||
perms = perm_model.objects.using(db_alias).all()
|
||||
default_action = Action.get_action_all()
|
||||
for perm in perms:
|
||||
perm.actions.add(default_action.id)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@@ -27,5 +15,4 @@ class Migration(migrations.Migration):
|
||||
name='actions',
|
||||
field=models.ManyToManyField(blank=True, related_name='permissions', to='perms.Action', verbose_name='Action'),
|
||||
),
|
||||
migrations.RunPython(set_default_action_to_existing_perms)
|
||||
]
|
||||
|
Reference in New Issue
Block a user