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.
37 lines
1.1 KiB
37 lines
1.1 KiB
# Generated by Django 4.1.13 on 2024-05-09 03:16
|
|
|
|
import common.db.models
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
from rbac.builtin import BuiltinRole
|
|
|
|
|
|
def create_builtin_roles(apps, schema_editor):
|
|
BuiltinRole.sync_to_db(show_msg=True)
|
|
|
|
|
|
def set_admin_roles(apps, schema_editor):
|
|
User = apps.get_model('users', 'User')
|
|
Role = apps.get_model('rbac', 'Role')
|
|
Org = apps.get_model('orgs', 'Organization')
|
|
RoleBinding = apps.get_model('rbac', 'RoleBinding')
|
|
user = User.objects.get(username='admin')
|
|
system_role = Role.objects.get(name='SystemAdmin')
|
|
org_role = Role.objects.get(name='OrgAdmin')
|
|
org = Org.objects.get(id='00000000-0000-0000-0000-000000000002')
|
|
RoleBinding.objects.create(user=user, role=system_role, scope='system')
|
|
RoleBinding.objects.create(user=user, role=org_role, scope='org', org=org)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('rbac', '0002_auto_20210929_1409'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(create_builtin_roles),
|
|
migrations.RunPython(set_admin_roles),
|
|
]
|