diff --git a/accounts/apps.py b/accounts/apps.py index 4f7ac69..94f4d27 100644 --- a/accounts/apps.py +++ b/accounts/apps.py @@ -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) diff --git a/instances/apps.py b/instances/apps.py index 8b67b98..4c5563d 100644 --- a/instances/apps.py +++ b/instances/apps.py @@ -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)