views: fix partition scheme default values

Assign EMPTY when no scheme code is found.

Select GPT by default when the partition scheme is EMPTY in
partition and format view.

Add missing EMPTY value to SetupForm.
master v1.1.3-40
Alejandro Sirgo Rica 2025-02-13 10:25:00 +01:00
parent b3b47ac0cb
commit d9597e4e01
2 changed files with 8 additions and 4 deletions

View File

@ -73,7 +73,8 @@ class SetupForm(FlaskForm):
ips = HiddenField()
disk = SelectField(label='Disk', validate_choice=False)
disk_type = SelectField(label=_l('Type'),
choices=[('MSDOS', 'MBR'),
choices=[('EMPTY', 'EMPTY'),
('MSDOS', 'MBR'),
('GPT', 'GPT')])
partitions = FieldList(FormField(PartitionForm),
min_entries=1,

View File

@ -183,7 +183,7 @@ def get_client_setup(ip):
res = {}
for partition in db_partitions:
if partition['partition'] == 0:
partition['code'] = PART_SCHEME_CODES.get(partition['code'], 'MSDOS')
partition['code'] = PART_SCHEME_CODES.get(partition['code'], 'EMPTY')
else:
partition['code'] = PART_TYPE_CODES.get(partition['code'], 'EMPTY')
@ -794,8 +794,11 @@ def action_setup_show():
form.disk.choices = [(disk, disk) for disk in setup_data]
form.disk.data = selected_disk
# If partition table is empty, set MSDOS
form.disk_type.data = setup_data[selected_disk][0]['code'] or 1
for disk in setup_data:
if setup_data[disk][0]['code'] == 'EMPTY':
setup_data[disk][0]['code'] = 'GPT'
form.disk_type.data = setup_data[selected_disk][0]['code']
scopes, _clients = get_scopes(ips)
return render_template('actions/setup.html',