From cbd6c3ee699c3ef2b365589463580b69bcf1a815 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 11 Apr 2018 12:23:35 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E6=B7=BB=E5=8A=A0=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/2018_04_11_migrate_permissions.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 utils/2018_04_11_migrate_permissions.sh diff --git a/utils/2018_04_11_migrate_permissions.sh b/utils/2018_04_11_migrate_permissions.sh new file mode 100644 index 000000000..5f98e5d4a --- /dev/null +++ b/utils/2018_04_11_migrate_permissions.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# + +python ../apps/manage.py shell << EOF +from perms.models import * + +for old in NodePermission.objects.all(): + perm = asset_perm_model.objects.using(db_alias).create( + name="{}-{}-{}".format( + old.node.value, + old.user_group.name, + old.system_user.name + ), + is_active=old.is_active, + date_expired=old.date_expired, + created_by=old.date_expired, + date_created=old.date_created, + comment=old.comment, + ) + perm.user_groups.add(old.user_group) + perm.nodes.add(old.node) + perm.system_users.add(old.system_user) +EOF +