1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-26 08:05:22 +00:00
webvirtcloud/appsettings/migrations/0008_auto_20220905_1459.py

33 lines
1.4 KiB
Python
Raw Normal View History

# Generated by Django 3.2.13 on 2022-06-30 07:17
from django.db import migrations
from django.utils.translation import gettext_lazy as _
def add_default_settings(apps, schema_editor):
setting = apps.get_model("appsettings", "AppSettings")
db_alias = schema_editor.connection.alias
setting.objects.using(db_alias).bulk_create([
setting(32, _("VM CD-ROM Device"), "INSTANCE_CDROM_ADD", "sata", "None,ide,sata,scsi,virtio", _("Add or not cdrom device while instance creating")),
setting(33, _("VM Video Type"), "INSTANCE_VIDEO_DEFAULT_TYPE", "vga", "None,virtio,vga,cirrus,vmvga,bochs,ramfb", _("Change instance default video type")),
setting(34, _("VM Input Device"), "INSTANCE_INPUT_DEFAULT_DEVICE", "default", "None,default,virtio,usb", _("Add or not input device with specify its type")),
])
def del_default_settings(apps, schema_editor):
setting = apps.get_model("appsettings", "AppSettings")
db_alias = schema_editor.connection.alias
setting.objects.using(db_alias).filter(key="INSTANCE_CDROM_ADD").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_VIDEO_DEFAULT_TYPE").delete()
setting.objects.using(db_alias).filter(key="INSTANCE_INPUT_DEFAULT_DEVICE").delete()
class Migration(migrations.Migration):
dependencies = [
('appsettings', '0007_auto_20220905_0918'),
]
operations = [
migrations.RunPython(add_default_settings, del_default_settings),
]