mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.1 KiB
32 lines
1.1 KiB
5 years ago
|
# Generated by Django 2.1.7 on 2019-09-16 02:57
|
||
5 years ago
|
|
||
|
from django.db import migrations, models
|
||
|
|
||
|
|
||
|
def migrate_system_user_from_remote_app_to_remote_app_perms(apps, schema_editor):
|
||
|
remote_app_perms_model = apps.get_model("perms", "RemoteAppPermission")
|
||
|
db_alias = schema_editor.connection.alias
|
||
|
perms = remote_app_perms_model.objects.using(db_alias).all()
|
||
|
for perm in perms:
|
||
|
system_users_ids = perm.remote_apps.values_list('system_user', flat=True)
|
||
|
perm.system_users.set(system_users_ids)
|
||
|
|
||
|
|
||
|
class Migration(migrations.Migration):
|
||
|
|
||
|
dependencies = [
|
||
5 years ago
|
('assets', '0038_auto_20190911_1634'),
|
||
|
('perms', '0008_auto_20190911_1907'),
|
||
5 years ago
|
]
|
||
|
|
||
|
operations = [
|
||
|
migrations.AddField(
|
||
|
model_name='remoteapppermission',
|
||
|
name='system_users',
|
||
|
field=models.ManyToManyField(related_name='granted_by_remote_app_permissions', to='assets.SystemUser', verbose_name='System user'),
|
||
|
),
|
||
|
migrations.RunPython(
|
||
|
code=migrate_system_user_from_remote_app_to_remote_app_perms,
|
||
|
),
|
||
|
]
|