Fixing Network Models
[pharos-tools.git] / dashboard / src / workflow / forms.py
index f781663..b40713f 100644 (file)
@@ -186,9 +186,9 @@ class BookingMetaForm(forms.Form):
         widget=NumberInput(
             attrs={
                 "type": "range",
-                'min': "0",
+                'min': "1",
                 "max": "21",
-                "value": "0"
+                "value": "1"
             }
         )
     )
@@ -330,7 +330,7 @@ class MultipleSelectFilterField(forms.Field):
 
 class FormUtils:
     @staticmethod
-    def getLabData():
+    def getLabData(multiple_selectable_hosts):
         """
         Gets all labs and thier host profiles and returns a serialized version the form can understand.
         Should be rewritten with a related query to make it faster
@@ -348,6 +348,8 @@ class FormUtils:
             slab['selected'] = 0
             slab['selectable'] = 1
             slab['follow'] = 1
+            if not multiple_selectable_hosts:
+                slab['follow'] = 0
             slab['multiple'] = 0
             items[slab['id']] = slab
             mapping[slab['id']] = []
@@ -361,7 +363,7 @@ class FormUtils:
                 shost['selected'] = 0
                 shost['selectable'] = 1
                 shost['follow'] = 0
-                shost['multiple'] = 1
+                shost['multiple'] = multiple_selectable_hosts
                 items[shost['id']] = shost
                 mapping[slab['id']].append(shost['id'])
                 if shost['id'] not in mapping:
@@ -374,7 +376,7 @@ class FormUtils:
         context = {
             'filter_objects': filter_objects,
             'mapping': mapping,
-            'items': items
+            'filter_items': items
         }
         return context
 
@@ -384,7 +386,7 @@ class HardwareDefinitionForm(forms.Form):
     def __init__(self, *args, **kwargs):
         selection_data = kwargs.pop("selection_data", False)
         super(HardwareDefinitionForm, self).__init__(*args, **kwargs)
-        attrs = FormUtils.getLabData()
+        attrs = FormUtils.getLabData(1)
         attrs['selection_data'] = selection_data
         self.fields['filter_field'] = MultipleSelectFilterField(
             widget=MultipleSelectFilterWidget(
@@ -461,7 +463,7 @@ class SnapshotHostSelectForm(forms.Form):
 
 class SnapshotMetaForm(forms.Form):
     name = forms.CharField()
-    description = forms.CharField()
+    description = forms.CharField(widget=forms.Textarea)
 
 
 class ConfirmationForm(forms.Form):