1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-03-22 18:44:49 +00:00

Added change password permission

Replaces SHOW_PROFILE_EDIT_PASSWORD option
Can be set on per user or per group basis
This commit is contained in:
Real-Gecko 2020-05-27 18:46:37 +06:00 committed by catborise
parent fec59b1dd7
commit 334d4bff18
8 changed files with 337 additions and 176 deletions

View file

@ -0,0 +1,24 @@
# Generated by Django 2.2.12 on 2020-05-27 12:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0002_addAdmin'),
]
operations = [
migrations.CreateModel(
name='PermissionSet',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
options={
'permissions': (('change_password', 'Can change password'),),
'managed': False,
'default_permissions': (),
},
),
]

View file

@ -0,0 +1,25 @@
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),
]

View file

@ -0,0 +1,24 @@
# Generated by Django 2.2.12 on 2020-06-02 10:04
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0004_apply_change_password'),
]
operations = [
migrations.AlterField(
model_name='userattributes',
name='max_cpus',
field=models.IntegerField(default=2, help_text='-1 for unlimited. Any integer value', validators=[django.core.validators.MinValueValidator(-1)]),
),
migrations.AlterField(
model_name='userattributes',
name='max_instances',
field=models.IntegerField(default=2, help_text='-1 for unlimited. Any integer value', validators=[django.core.validators.MinValueValidator(-1)]),
),
]

View file

@ -1,9 +1,11 @@
from django.db.models import Model, BooleanField, IntegerField, CharField from django.conf import settings
from django.db.models import ForeignKey, OneToOneField
from django.db.models import CASCADE, DO_NOTHING
from django.contrib.auth.models import User from django.contrib.auth.models import User
from instances.models import Instance
from django.core.validators import MinValueValidator from django.core.validators import MinValueValidator
from django.db.models import (CASCADE, DO_NOTHING, BooleanField, CharField,
ForeignKey, IntegerField, Model, OneToOneField)
from django.utils.translation import ugettext_lazy as _
from instances.models import Instance
class UserInstance(Model): class UserInstance(Model):
@ -29,10 +31,26 @@ class UserSSHKey(Model):
class UserAttributes(Model): class UserAttributes(Model):
user = OneToOneField(User, on_delete=CASCADE) user = OneToOneField(User, on_delete=CASCADE)
can_clone_instances = BooleanField(default=True) can_clone_instances = BooleanField(default=True)
max_instances = IntegerField(default=1, help_text="-1 for unlimited. Any integer value", validators=[MinValueValidator(-1), ]) max_instances = IntegerField(default=2,
max_cpus = IntegerField(default=1, help_text="-1 for unlimited. Any integer value", validators=[MinValueValidator(-1)]) help_text="-1 for unlimited. Any integer value",
max_memory = IntegerField(default=2048, help_text="-1 for unlimited. Any integer value", validators=[MinValueValidator(-1)]) validators=[
max_disk_size = IntegerField(default=20, help_text="-1 for unlimited. Any integer value", validators=[MinValueValidator(-1)]) MinValueValidator(-1),
])
max_cpus = IntegerField(
default=2,
help_text="-1 for unlimited. Any integer value",
validators=[MinValueValidator(-1)],
)
max_memory = IntegerField(
default=2048,
help_text="-1 for unlimited. Any integer value",
validators=[MinValueValidator(-1)],
)
max_disk_size = IntegerField(
default=20,
help_text="-1 for unlimited. Any integer value",
validators=[MinValueValidator(-1)],
)
@staticmethod @staticmethod
def create_missing_userattributes(user): def create_missing_userattributes(user):
@ -58,3 +76,16 @@ class UserAttributes(Model):
def __unicode__(self): def __unicode__(self):
return self.user.username return self.user.username
class PermissionSet(Model):
"""
Dummy model for holding set of permissions we need to be automatically added by Django
"""
class Meta:
default_permissions = ()
permissions = (
('change_password', _('Can change password')),
)
managed = False

View file

@ -3,116 +3,120 @@
{% load tags_fingerprint %} {% load tags_fingerprint %}
{% block title %}{% trans "Profile" %}{% endblock %} {% block title %}{% trans "Profile" %}{% endblock %}
{% block content %} {% block content %}
<!-- Page Heading --> <!-- Page Heading -->
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<h2 class="page-header">{% trans "Profile" %}</h2> <h2 class="page-header">{% trans "Profile" %}</h2>
</div>
</div>
<!-- /.row -->
{% include 'errors_block.html' %}
<div class="row">
<div class="col-lg-12">
<h3 class="page-header">{% trans "Edit Profile" %}</h3>
<form method="post" action="" role="form" aria-label="Edit user info form">{% csrf_token %}
<div class="form-group">
<label class="col-sm-2 col-form-label">{% trans "Login" %}</label>
<div class="col-sm-4">
<input type="text" class="form-control" value="{{ request.user.username }}" disabled>
</div> </div>
</div> </div>
<!-- /.row --> <div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Username" %}</label>
{% include 'errors_block.html' %} <div class="col-sm-4">
<input type="text" class="form-control" name="username" value="{{ request.user.first_name }}"
<div class="row"> pattern="[0-9a-zA-Z]+">
<div class="col-lg-12">
<h3 class="page-header">{% trans "Edit Profile" %}</h3>
<form method="post" action="" role="form" aria-label="Edit user info form">{% csrf_token %}
<div class="form-group">
<label class="col-sm-2 col-form-label">{% trans "Login" %}</label>
<div class="col-sm-4">
<input type="text" class="form-control" value="{{ request.user.username }}" disabled>
</div>
</div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Username" %}</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="username" value="{{ request.user.first_name }}" pattern="[0-9a-zA-Z]+">
</div>
</div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Email" %}</label>
<div class="col-sm-4">
<input type="email" class="form-control" name="email" value="{{ request.user.email }}">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">{% trans "Change" %}</button>
</div>
</div>
</form>
{% if show_profile_edit_password == 'True' %}
<h3 class="page-header">{% trans "Edit Password" %}</h3>
<form method="post" action="" role="form" aria-label="Edit user password form">{% csrf_token %}
<div class="form-group">
<label class="col-sm-2 col-form-label">{% trans "Old" %}</label>
<div class="col-sm-4">
<input type="password" class="form-control" name="oldpasswd" value="">
</div>
</div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "New" %}</label>
<div class="col-sm-4">
<input type="password" class="form-control" name="passwd1" value="">
</div>
</div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Retry" %}</label>
<div class="col-sm-4">
<input type="password" class="form-control" name="passwd2" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">{% trans "Change" %}</button>
</div>
</div>
</form>
{% endif %}
<h3 class="page-header">{% trans "SSH Keys" %}</h3>
{% if publickeys %}
<div class="col-lg-12">
<div class="table-responsive">
<table class="table table-hover">
<tbody class="text-center">
{% for key in publickeys %}
<tr>
<td>{{ key.keyname }} ({% ssh_to_fingerprint key.keypublic %})</td>
<td>
<form action="" method="post" role="form" aria-label="Delete user public key form">{% csrf_token %}
<input type="hidden" name="keyid" value="{{ key.id }}"/>
<button type="submit" class="btn btn-sm btn-secondary" name="keydelete" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
<span class="fa fa-trash"></span>
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
<form method="post" action="" role="form" aria-label="Add key to user form">{% csrf_token %}
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Key name" %}</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="keyname" placeholder="{% trans "Enter Name" %}">
</div>
</div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Public key" %}</label>
<div class="col-sm-8">
<textarea name="keypublic" class="form-control" rows="6" placeholder="{% trans "Enter Public Key" %}"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">{% trans "Add" %}</button>
</div>
</div>
</form>
</div> </div>
</div> </div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Email" %}</label>
<div class="col-sm-4">
<input type="email" class="form-control" name="email" value="{{ request.user.email }}">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">{% trans "Change" %}</button>
</div>
</div>
</form>
{% if perms.accounts.change_password %}
<h3 class="page-header">{% trans "Edit Password" %}</h3>
<form method="post" action="" role="form" aria-label="Edit user password form">{% csrf_token %}
<div class="form-group">
<label class="col-sm-2 col-form-label">{% trans "Old" %}</label>
<div class="col-sm-4">
<input type="password" class="form-control" name="oldpasswd" value="">
</div>
</div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "New" %}</label>
<div class="col-sm-4">
<input type="password" class="form-control" name="passwd1" value="">
</div>
</div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Retry" %}</label>
<div class="col-sm-4">
<input type="password" class="form-control" name="passwd2" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">{% trans "Change" %}</button>
</div>
</div>
</form>
{% endif %}
<h3 class="page-header">{% trans "SSH Keys" %}</h3>
{% if publickeys %}
<div class="col-lg-12">
<div class="table-responsive">
<table class="table table-hover">
<tbody class="text-center">
{% for key in publickeys %}
<tr>
<td>{{ key.keyname }} ({% ssh_to_fingerprint key.keypublic %})</td>
<td>
<form action="" method="post" role="form" aria-label="Delete user public key form">
{% csrf_token %}
<input type="hidden" name="keyid" value="{{ key.id }}" />
<button type="submit" class="btn btn-sm btn-secondary" name="keydelete"
title="{% trans "Delete" %}"
onclick="return confirm('{% trans "Are you sure?" %}')">
<span class="fa fa-trash"></span>
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
<form method="post" action="" role="form" aria-label="Add key to user form">{% csrf_token %}
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Key name" %}</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="keyname" placeholder="{% trans "Enter Name" %}">
</div>
</div>
<div class="form-group bridge_name_form_group_dhcp">
<label class="col-sm-2 col-form-label">{% trans "Public key" %}</label>
<div class="col-sm-8">
<textarea name="keypublic" class="form-control" rows="6"
placeholder="{% trans "Enter Public Key" %}"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">{% trans "Add" %}</button>
</div>
</div>
</form>
</div>
</div>
{% endblock %} {% endblock %}

View file

@ -13,6 +13,7 @@ from instances.models import Instance
import sass import sass
import os import os
def profile(request): def profile(request):
""" """
:param request: :param request:
@ -22,7 +23,6 @@ def profile(request):
error_messages = [] error_messages = []
# user = User.objects.get(id=request.user.id) # user = User.objects.get(id=request.user.id)
publickeys = UserSSHKey.objects.filter(user_id=request.user.id) publickeys = UserSSHKey.objects.filter(user_id=request.user.id)
show_profile_edit_password = AppSettings.objects.get(key="SHOW_PROFILE_EDIT_PASSWORD").value
if request.method == 'POST': if request.method == 'POST':
if 'username' in request.POST: if 'username' in request.POST:
@ -60,7 +60,8 @@ def profile(request):
msg = _("Invalid characters in public key") msg = _("Invalid characters in public key")
error_messages.append(msg) error_messages.append(msg)
if not error_messages: if not error_messages:
addkeypublic = UserSSHKey(user_id=request.user.id, keyname=keyname, keypublic=keypublic) addkeypublic = UserSSHKey(
user_id=request.user.id, keyname=keyname, keypublic=keypublic)
addkeypublic.save() addkeypublic.save()
return HttpResponseRedirect(request.get_full_path()) return HttpResponseRedirect(request.get_full_path())
if 'keydelete' in request.POST: if 'keydelete' in request.POST:
@ -70,6 +71,7 @@ def profile(request):
return HttpResponseRedirect(request.get_full_path()) return HttpResponseRedirect(request.get_full_path())
return render(request, 'profile.html', locals()) return render(request, 'profile.html', locals())
@superuser_only @superuser_only
def account(request, user_id): def account(request, user_id):
""" """
@ -105,15 +107,18 @@ def account(request, user_id):
inst_id = request.POST.get('inst_id', '') inst_id = request.POST.get('inst_id', '')
if AppSettings.objects.get(key="ALLOW_INSTANCE_MULTIPLE_OWNER").value == 'True': if AppSettings.objects.get(key="ALLOW_INSTANCE_MULTIPLE_OWNER").value == 'True':
check_inst = UserInstance.objects.filter(instance_id=int(inst_id), user_id=int(user_id)) check_inst = UserInstance.objects.filter(
instance_id=int(inst_id), user_id=int(user_id))
else: else:
check_inst = UserInstance.objects.filter(instance_id=int(inst_id)) check_inst = UserInstance.objects.filter(
instance_id=int(inst_id))
if check_inst: if check_inst:
msg = _("Instance already added") msg = _("Instance already added")
error_messages.append(msg) error_messages.append(msg)
else: else:
add_user_inst = UserInstance(instance_id=int(inst_id), user_id=int(user_id)) add_user_inst = UserInstance(
instance_id=int(inst_id), user_id=int(user_id))
add_user_inst.save() add_user_inst.save()
return HttpResponseRedirect(request.get_full_path()) return HttpResponseRedirect(request.get_full_path())

View file

@ -2,72 +2,121 @@
from django.db import migrations from django.db import migrations
def add_default_settings(apps, schema_editor): def add_default_settings(apps, schema_editor):
setting = apps.get_model("appsettings", "AppSettings") setting = apps.get_model("appsettings", "AppSettings")
db_alias = schema_editor.connection.alias db_alias = schema_editor.connection.alias
setting.objects.using(db_alias).bulk_create([ setting.objects.using(db_alias).bulk_create([
setting(1, "Theme", "BOOTSTRAP_THEME", "flaty", "", "Bootstrap CSS & Bootswatch Theme"), setting(1, "Theme", "BOOTSTRAP_THEME", "flaty",
setting(2, "Theme SASS Path", "SASS_DIR", "dev/scss/", "", "Bootstrap SASS & Bootswatch SASS Directory"), "", "Bootstrap CSS & Bootswatch Theme"),
setting(3, "All Instances View Style", "VIEW_INSTANCES_LIST_STYLE", "grouped", "grouped,nongrouped", "All instances list style"), setting(2, "Theme SASS Path", "SASS_DIR", "dev/scss/",
setting(4, "Account View Style", "VIEW_ACCOUNTS_STYLE", "grid", "grid,list", "User accounts view style"), "", "Bootstrap SASS & Bootswatch SASS Directory"),
setting(5, "Logs per Page", "LOGS_PER_PAGE", "100", "", "Pagination for logs"), setting(3, "All Instances View Style", "VIEW_INSTANCES_LIST_STYLE",
setting(6, "Multiple Owner for VM ", "ALLOW_INSTANCE_MULTIPLE_OWNER", "True", "True,False", "Allow to have multiple owner for instance"), "grouped", "grouped,nongrouped", "All instances list style"),
setting(7, "Quota Debug", "QUOTA_DEBUG", "True", "True,False", "Debug for user quotas"), setting(4, "Account View Style", "VIEW_ACCOUNTS_STYLE",
setting(8, "Disk Format", "INSTANCE_VOLUME_DEFAULT_FORMAT", "qcow2", "raw,qcow,qcow2", "Instance disk format"), "grid", "grid,list", "User accounts view style"),
setting(9, "Disk Bus", "INSTANCE_VOLUME_DEFAULT_BUS", "virtio", "virtio,scsi,ide,usb,sata", "Instance disk bus type"), setting(5, "Logs per Page", "LOGS_PER_PAGE",
setting(10, "Disk SCSI Controller", "INSTANCE_VOLUME_DEFAULT_SCSI_CONTROLLER", "virtio-scsi", "virtio-scsi, lsilogic, virtio-blk", "SCSI controller type"), "100", "", "Pagination for logs"),
setting(11, "Disk Cache", "INSTANCE_VOLUME_DEFAULT_CACHE", "directsync", "default,directsync,none,unsafe,writeback,writethrough", "Disk volume cache type"), setting(6, "Multiple Owner for VM ", "ALLOW_INSTANCE_MULTIPLE_OWNER",
setting(12, "Disk IO Type", "INSTANCE_VOLUME_DEFAULT_IO", "default", "default,native,threads", "Volume io modes"), "True", "True,False", "Allow to have multiple owner for instance"),
setting(13, "Disk Detect Zeroes", "INSTANCE_VOLUME_DEFAULT_DETECT_ZEROES", "default", "default,on,off,unmap", "Volume detect zeroes mode"), setting(7, "Quota Debug", "QUOTA_DEBUG", "True",
setting(14, "Disk Discard", "INSTANCE_VOLUME_DEFAULT_DISCARD", "default", "default,unmap,ignore", "Volume discard mode"), "True,False", "Debug for user quotas"),
setting(15, "Disk Owner UID", "INSTANCE_VOLUME_DEFAULT_OWNER_UID", "0", "", "Owner UID: up to os, 0=root, 107=qemu or libvirt-bin(for ubuntu)"), setting(8, "Disk Format", "INSTANCE_VOLUME_DEFAULT_FORMAT",
setting(16, "Disk Owner GID", "INSTANCE_VOLUME_DEFAULT_OWNER_GID", "0", "", "Owner GID: up to os, 0=root, 107=qemu or libvirt-bin(for ubuntu)"), "qcow2", "raw,qcow,qcow2", "Instance disk format"),
setting(17, "VM CPU Mode", "INSTANCE_CPU_DEFAULT_MODE", "host-model", "no-model,host-model,host-passthrough,custom", "Cpu modes"), setting(9, "Disk Bus", "INSTANCE_VOLUME_DEFAULT_BUS", "virtio",
setting(18, "VM Machine Type", "INSTANCE_MACHINE_DEFAULT_TYPE", "q35", "q35,x86_64", "Chipset/Machine type"), "virtio,scsi,ide,usb,sata", "Instance disk bus type"),
setting(19, "VM Firmware Type", "INSTANCE_FIRMWARE_DEFAULT_TYPE", "BIOS", "BIOS,UEFI", "Firmware type for x86_64"), setting(10, "Disk SCSI Controller", "INSTANCE_VOLUME_DEFAULT_SCSI_CONTROLLER",
setting(20, "VM Architecture Type", "INSTANCE_ARCH_DEFAULT_TYPE", "x86_64", "x86_64,i686", "Architecture type: x86_64, i686, etc"), "virtio-scsi", "virtio-scsi, lsilogic, virtio-blk", "SCSI controller type"),
setting(21, "VM Console Type", "QEMU_CONSOLE_DEFAULT_TYPE", "vnc", "vnc,spice", "Default console type"), setting(11, "Disk Cache", "INSTANCE_VOLUME_DEFAULT_CACHE", "directsync",
setting(22, "VM Clone Name Prefix", "CLONE_INSTANCE_DEFAULT_PREFIX", "instance", "True,False", "Prefix for cloned instance name"), "default,directsync,none,unsafe,writeback,writethrough", "Disk volume cache type"),
setting(23, "VM Clone Auto Name", "CLONE_INSTANCE_AUTO_NAME", "False", "True,False", "Generated name for cloned instance"), setting(12, "Disk IO Type", "INSTANCE_VOLUME_DEFAULT_IO",
setting(24, "VM Clone Auto Migrate", "CLONE_INSTANCE_AUTO_MIGRATE", "False", "True,False", "Auto migrate instance after clone"), "default", "default,native,threads", "Volume io modes"),
setting(25, "VM Bottom Bar", "VIEW_INSTANCE_DETAIL_BOTTOM_BAR", "True", "True,False", "Bottom navbar for instance details"), setting(13, "Disk Detect Zeroes", "INSTANCE_VOLUME_DEFAULT_DETECT_ZEROES",
setting(26, "Show Access Root Pass", "SHOW_ACCESS_ROOT_PASSWORD", "False", "True,False", "Show access root password"), "default", "default,on,off,unmap", "Volume detect zeroes mode"),
setting(27, "Show Access SSH Keys", "SHOW_ACCESS_SSH_KEYS", "False", "True,False", "Show access ssh keys"), setting(14, "Disk Discard", "INSTANCE_VOLUME_DEFAULT_DISCARD",
setting(28, "Show Profile Edit Pass", "SHOW_PROFILE_EDIT_PASSWORD", "False", "True,False", "Show profile edit password"), "default", "default,unmap,ignore", "Volume discard mode"),
setting(15, "Disk Owner UID", "INSTANCE_VOLUME_DEFAULT_OWNER_UID", "0",
"", "Owner UID: up to os, 0=root, 107=qemu or libvirt-bin(for ubuntu)"),
setting(16, "Disk Owner GID", "INSTANCE_VOLUME_DEFAULT_OWNER_GID", "0",
"", "Owner GID: up to os, 0=root, 107=qemu or libvirt-bin(for ubuntu)"),
setting(17, "VM CPU Mode", "INSTANCE_CPU_DEFAULT_MODE", "host-model",
"no-model,host-model,host-passthrough,custom", "Cpu modes"),
setting(18, "VM Machine Type", "INSTANCE_MACHINE_DEFAULT_TYPE",
"q35", "q35,x86_64", "Chipset/Machine type"),
setting(19, "VM Firmware Type", "INSTANCE_FIRMWARE_DEFAULT_TYPE",
"BIOS", "BIOS,UEFI", "Firmware type for x86_64"),
setting(20, "VM Architecture Type", "INSTANCE_ARCH_DEFAULT_TYPE",
"x86_64", "x86_64,i686", "Architecture type: x86_64, i686, etc"),
setting(21, "VM Console Type", "QEMU_CONSOLE_DEFAULT_TYPE",
"vnc", "vnc,spice", "Default console type"),
setting(22, "VM Clone Name Prefix", "CLONE_INSTANCE_DEFAULT_PREFIX",
"instance", "True,False", "Prefix for cloned instance name"),
setting(23, "VM Clone Auto Name", "CLONE_INSTANCE_AUTO_NAME",
"False", "True,False", "Generated name for cloned instance"),
setting(24, "VM Clone Auto Migrate", "CLONE_INSTANCE_AUTO_MIGRATE",
"False", "True,False", "Auto migrate instance after clone"),
setting(25, "VM Bottom Bar", "VIEW_INSTANCE_DETAIL_BOTTOM_BAR",
"True", "True,False", "Bottom navbar for instance details"),
setting(26, "Show Access Root Pass", "SHOW_ACCESS_ROOT_PASSWORD",
"False", "True,False", "Show access root password"),
setting(27, "Show Access SSH Keys", "SHOW_ACCESS_SSH_KEYS",
"False", "True,False", "Show access ssh keys"),
]) ])
def del_default_settings(apps, schema_editor): def del_default_settings(apps, schema_editor):
setting = apps.get_model("appsettings", "AppSettings") setting = apps.get_model("appsettings", "AppSettings")
db_alias = schema_editor.connection.alias db_alias = schema_editor.connection.alias
setting.objects.using(db_alias).filter(key="QEMU_CONSOLE_DEFAULT_TYPE").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="ALLOW_INSTANCE_MULTIPLE_OWNER").delete() key="QEMU_CONSOLE_DEFAULT_TYPE").delete()
setting.objects.using(db_alias).filter(key="CLONE_INSTANCE_DEFAULT_PREFIX").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="CLONE_INSTANCE_AUTO_NAME").delete() key="ALLOW_INSTANCE_MULTIPLE_OWNER").delete()
setting.objects.using(db_alias).filter(key="CLONE_INSTANCE_AUTO_MIGRATE").delete() setting.objects.using(db_alias).filter(
key="CLONE_INSTANCE_DEFAULT_PREFIX").delete()
setting.objects.using(db_alias).filter(
key="CLONE_INSTANCE_AUTO_NAME").delete()
setting.objects.using(db_alias).filter(
key="CLONE_INSTANCE_AUTO_MIGRATE").delete()
setting.objects.using(db_alias).filter(key="LOGS_PER_PAGE").delete() setting.objects.using(db_alias).filter(key="LOGS_PER_PAGE").delete()
setting.objects.using(db_alias).filter(key="QUOTA_DEBUG").delete() setting.objects.using(db_alias).filter(key="QUOTA_DEBUG").delete()
setting.objects.using(db_alias).filter(key="VIEW_ACCOUNTS_STYLE").delete() setting.objects.using(db_alias).filter(key="VIEW_ACCOUNTS_STYLE").delete()
setting.objects.using(db_alias).filter(key="VIEW_INSTANCES_LIST_STYLE").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="VIEW_INSTANCE_DETAIL_BOTTOM_BAR").delete() key="VIEW_INSTANCES_LIST_STYLE").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_FORMAT").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_BUS").delete() key="VIEW_INSTANCE_DETAIL_BOTTOM_BAR").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_SCSI_CONTROLLER").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_CACHE").delete() key="INSTANCE_VOLUME_DEFAULT_FORMAT").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_IO").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_DETECT_ZEROES").delete() key="INSTANCE_VOLUME_DEFAULT_BUS").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_DISCARD").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_OWNER_UID").delete() key="INSTANCE_VOLUME_DEFAULT_SCSI_CONTROLLER").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_VOLUME_DEFAULT_OWNER_GID").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="INSTANCE_CPU_DEFAULT_MODE").delete() key="INSTANCE_VOLUME_DEFAULT_CACHE").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_MACHINE_DEFAULT_TYPE").delete() setting.objects.using(db_alias).filter(
setting.objects.using(db_alias).filter(key="INSTANCE_FIRMWARE_DEFAULT_TYPE").delete() key="INSTANCE_VOLUME_DEFAULT_IO").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_ARCH_DEFAULT_TYPE").delete() setting.objects.using(db_alias).filter(
key="INSTANCE_VOLUME_DEFAULT_DETECT_ZEROES").delete()
setting.objects.using(db_alias).filter(
key="INSTANCE_VOLUME_DEFAULT_DISCARD").delete()
setting.objects.using(db_alias).filter(
key="INSTANCE_VOLUME_DEFAULT_OWNER_UID").delete()
setting.objects.using(db_alias).filter(
key="INSTANCE_VOLUME_DEFAULT_OWNER_GID").delete()
setting.objects.using(db_alias).filter(
key="INSTANCE_CPU_DEFAULT_MODE").delete()
setting.objects.using(db_alias).filter(
key="INSTANCE_MACHINE_DEFAULT_TYPE").delete()
setting.objects.using(db_alias).filter(
key="INSTANCE_FIRMWARE_DEFAULT_TYPE").delete()
setting.objects.using(db_alias).filter(
key="INSTANCE_ARCH_DEFAULT_TYPE").delete()
setting.objects.using(db_alias).filter(key="BOOTSTRAP_THEME").delete() setting.objects.using(db_alias).filter(key="BOOTSTRAP_THEME").delete()
setting.objects.using(db_alias).filter(key="SASS_DIR").delete() setting.objects.using(db_alias).filter(key="SASS_DIR").delete()
setting.objects.using(db_alias).filter(key="SHOW_ACCESS_ROOT_PASSWORD").delete() setting.objects.using(db_alias).filter(
key="SHOW_ACCESS_ROOT_PASSWORD").delete()
setting.objects.using(db_alias).filter(key="SHOW_ACCESS_SSH_KEYS").delete() setting.objects.using(db_alias).filter(key="SHOW_ACCESS_SSH_KEYS").delete()
setting.objects.using(db_alias).filter(key="SHOW_PROFILE_EDIT_PASSWORD").delete()
class Migration(migrations.Migration): class Migration(migrations.Migration):

View file

@ -157,6 +157,5 @@ LIBVIRT_KEEPALIVE_INTERVAL = 5
LIBVIRT_KEEPALIVE_COUNT = 5 LIBVIRT_KEEPALIVE_COUNT = 5
ALLOW_EMPTY_PASSWORD = True ALLOW_EMPTY_PASSWORD = True
NEW_USER_DEFAULT_INSTANCES = []