De-uglify default template in Global Settings
Replaced old, manual vm list with a nicer, less disgusting utils.prepare_vm_choice approach.
This commit is contained in:
		
							parent
							
								
									84d7e8bf9c
								
							
						
					
					
						commit
						4882013a32
					
				| @ -60,9 +60,6 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, | |||||||
|         self.__init_updates__() |         self.__init_updates__() | ||||||
| 
 | 
 | ||||||
|     def __init_system_defaults__(self): |     def __init_system_defaults__(self): | ||||||
|         all_vms = [vm for vm in self.qvm_collection.domains |  | ||||||
|                    if (not vm.features.get('internal', False)) and vm.qid != 0] |  | ||||||
| 
 |  | ||||||
|         # set up updatevm choice |         # set up updatevm choice | ||||||
|         self.update_vm_vmlist, self.update_vm_idx = utils.prepare_vm_choice( |         self.update_vm_vmlist, self.update_vm_idx = utils.prepare_vm_choice( | ||||||
|             self.update_vm_combo, self.qvm_collection, 'updatevm', |             self.update_vm_combo, self.qvm_collection, 'updatevm', | ||||||
| @ -85,18 +82,13 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, | |||||||
|                 allow_none=True) |                 allow_none=True) | ||||||
| 
 | 
 | ||||||
|         # default template |         # default template | ||||||
|         templates = [vm for vm in all_vms if vm.klass == 'TemplateVM'] |         self.default_template_vmlist, self.default_template_idx = \ | ||||||
|         self.template_idx = -1 |             utils.prepare_vm_choice( | ||||||
| 
 |                 self.default_template_combo, | ||||||
|         current_template = self.qvm_collection.default_template |                 self.qvm_collection, 'default_template', | ||||||
|         for (i, vm) in enumerate(templates): |                 None, | ||||||
|             text = vm.name |                 filter_function=(lambda vm: vm.klass == 'TemplateVM') | ||||||
|             if vm is current_template: |             ) | ||||||
|                 self.template_idx = i |  | ||||||
|                 text += self.tr(" (current)") |  | ||||||
|             self.default_template_combo.insertItem(i, text) |  | ||||||
|         if current_template is not None: |  | ||||||
|             self.default_template_combo.setCurrentIndex(self.template_idx) |  | ||||||
| 
 | 
 | ||||||
|     def __apply_system_defaults__(self): |     def __apply_system_defaults__(self): | ||||||
|         # upatevm |         # upatevm | ||||||
| @ -112,12 +104,9 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, | |||||||
|             self.default_netvm_vmlist[self.default_netvm_combo.currentIndex()] |             self.default_netvm_vmlist[self.default_netvm_combo.currentIndex()] | ||||||
| 
 | 
 | ||||||
|         # default template |         # default template | ||||||
|         if self.default_template_combo.currentIndex() != self.template_idx: |         self.qvm_collection.default_template = \ | ||||||
|             name = str(self.default_template_combo.currentText()) |             self.default_template_vmlist[ | ||||||
|             name = name.split(' ')[0] |                 self.default_template_combo.currentIndex()] | ||||||
|             vm = self.qvm_collection.domains[name] |  | ||||||
| 
 |  | ||||||
|             self.qvm_collection.default_template = vm |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     def __init_kernel_defaults__(self): |     def __init_kernel_defaults__(self): | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Marta Marczykowska-Górecka
						Marta Marczykowska-Górecka