mirror of
https://github.com/retspen/webvirtcloud
synced 2026-03-22 10:34:49 +00:00
Fixe migrations for new deployments
This commit is contained in:
parent
f790c52704
commit
fd25d12f92
4 changed files with 1 additions and 79 deletions
|
|
@ -16,7 +16,7 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
],
|
||||
options={
|
||||
'permissions': (('change_password', 'Can change password'),),
|
||||
'permissions': (('change_password', 'Can change password'), ),
|
||||
'managed': False,
|
||||
'default_permissions': (),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
def apply_change_password(apps, schema_editor):
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User, Permission
|
||||
|
||||
if hasattr(settings, 'SHOW_PROFILE_EDIT_PASSWORD'):
|
||||
if settings.SHOW_PROFILE_EDIT_PASSWORD:
|
||||
permission = Permission.objects.get(codename='change_password')
|
||||
users = User.objects.all()
|
||||
user: User
|
||||
for user in users:
|
||||
user.user_permissions.add(permission)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0003_permissionset'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(apply_change_password),
|
||||
]
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# Generated by Django 2.2.12 on 2020-05-28 04:24
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0004_apply_change_password'),
|
||||
('instances', '0003_migrate_can_clone_instances'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='userattributes',
|
||||
name='can_clone_instances',
|
||||
),
|
||||
]
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
def migrate_can_clone_instances(apps, schema_editor):
|
||||
from django.contrib.auth.models import User, Permission
|
||||
user: User
|
||||
users = User.objects.all()
|
||||
|
||||
permission = Permission.objects.get(codename='clone_instances')
|
||||
|
||||
for user in users:
|
||||
if user.userattributes.can_clone_instances:
|
||||
user.user_permissions.add(permission)
|
||||
|
||||
|
||||
def reverse_can_clone_instances(apps, schema_editor):
|
||||
from django.contrib.auth.models import User, Permission
|
||||
user: User
|
||||
users = User.objects.all()
|
||||
|
||||
permission = Permission.objects.get(codename='clone_instances')
|
||||
|
||||
for user in users:
|
||||
user.user_permissions.remove(permission)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('instances', '0002_permissionset'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migrate_can_clone_instances, reverse_can_clone_instances),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue