mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-21 15:58:52 +00:00
* [Update] 修改RemoteApp关联的系统用户:从RemoteApp中转移到RemoteAppPermission中(未提交迁移文件) * [Update] 修改RemoteApp关联的系统用户:提交迁移文件 * [Update] 修改RemoteApp关联的系统用户:修改迁移文件 * [Update] 修改迁移文件1 * [Update] 修改迁移文件2 * [Update] 修改迁移文件3 * [Update] 修改RemoteAppPermsUtil获取系统用户的逻辑
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# Generated by Django 2.1.7 on 2019-09-09 09:09
|
|
|
|
from django.db import migrations, models
|
|
from assets.models import SystemUser
|
|
|
|
|
|
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 = [
|
|
('assets', '0037_auto_20190724_2002'),
|
|
('perms', '0007_remove_assetpermission_actions'),
|
|
]
|
|
|
|
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,
|
|
),
|
|
]
|