1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +00:00

fix:move from accounts, after permission migrate applyings to instances

This commit is contained in:
catborise 2020-07-20 10:44:33 +03:00
parent 30948ca445
commit abfbc54594
2 changed files with 13 additions and 14 deletions

View file

@ -24,19 +24,6 @@ def apply_change_password(sender, **kwargs):
user.user_permissions.remove(permission)
print('\033[1mDon`t forget to remove the option from settings.py\033[0m')
def apply_passwordless_console(sender, **kwargs):
'''
Apply new passwordless_console permission for all users
'''
from django.conf import settings
from django.contrib.auth.models import User, Permission
print('\033[92mApplying permission passwordless_console for all users\033[0m')
users = User.objects.all()
permission = Permission.objects.get(codename='passwordless_console')
for user in users:
user.user_permissions.add(permission)
def create_admin(sender, **kwargs):
'''
@ -62,4 +49,3 @@ class AccountsConfig(AppConfig):
def ready(self):
post_migrate.connect(apply_change_password, sender=self)
post_migrate.connect(create_admin, sender=self)
post_migrate.connect(apply_passwordless_console, sender=self)

View file

@ -22,6 +22,18 @@ def migrate_can_clone_instances(sender, **kwargs):
user.user_permissions.add(permission)
break
def apply_passwordless_console(sender, **kwargs):
'''
Apply new passwordless_console permission for all users
'''
from django.conf import settings
from django.contrib.auth.models import User, Permission
print('\033[92mApplying permission passwordless_console for all users\033[0m')
users = User.objects.all()
permission = Permission.objects.get(codename='passwordless_console')
for user in users:
user.user_permissions.add(permission)
class InstancesConfig(AppConfig):
name = 'instances'
@ -29,3 +41,4 @@ class InstancesConfig(AppConfig):
def ready(self):
post_migrate.connect(migrate_can_clone_instances, sender=self)
post_migrate.connect(apply_passwordless_console, sender=self)