aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSean Smith <ssmith@iol.unh.edu>2021-04-06 16:18:36 -0400
committerSean Smith <ssmith@iol.unh.edu>2021-04-06 16:19:18 -0400
commit2271036232bce7ce4f2136ee6e031e9e77d9c1c2 (patch)
tree395d52187e579101ca7f5a583cde44925a524107 /src
parentf1456220fcc098cb0f5e9fc60124680ff8aba6af (diff)
Restrict image on multi-node booking
Change-Id: I280dba83bceed74195a77b28f3016421c462cc5a Signed-off-by: Sean Smith <ssmith@iol.unh.edu>
Diffstat (limited to 'src')
-rw-r--r--src/booking/forms.py12
-rw-r--r--src/static/js/dashboard.js7
2 files changed, 16 insertions, 3 deletions
diff --git a/src/booking/forms.py b/src/booking/forms.py
index e7be70f..fe1ff3f 100644
--- a/src/booking/forms.py
+++ b/src/booking/forms.py
@@ -35,10 +35,18 @@ class QuickBookingForm(forms.Form):
super(QuickBookingForm, self).__init__(data=data, **kwargs)
+ image_help_text = 'Image can be set only for single-node bookings. For multi-node bookings set image through Design a POD.'
self.fields["image"] = forms.ModelChoiceField(
Image.objects.filter(public=True) | Image.objects.filter(owner=user), required=False
)
+ self.fields['image'].widget.attrs.update({
+ 'class': 'has-popover',
+ 'data-content': image_help_text,
+ 'data-placement': 'bottom',
+ 'data-container': 'body'
+ })
+
self.fields['users'] = SearchableSelectMultipleField(
queryset=UserProfile.objects.select_related('user').exclude(user=user),
items=get_user_items(exclude=user),
@@ -59,10 +67,10 @@ class QuickBookingForm(forms.Form):
self.fields['filter_field'] = MultipleSelectFilterField(widget=MultipleSelectFilterWidget(**lab_data))
- help_text = 'Hostname can be set only for single-node bookings. For multi-node bookings set hostname through Design a POD.'
+ hostname_help_text = 'Hostname can be set only for single-node bookings. For multi-node bookings set hostname through Design a POD.'
self.fields['hostname'].widget.attrs.update({
'class': 'has-popover',
- 'data-content': help_text,
+ 'data-content': hostname_help_text,
'data-placement': 'top',
'data-container': 'body'
})
diff --git a/src/static/js/dashboard.js b/src/static/js/dashboard.js
index dfbb157..6395df0 100644
--- a/src/static/js/dashboard.js
+++ b/src/static/js/dashboard.js
@@ -409,6 +409,7 @@ class MultipleSelectFilterWidget {
reserveResource(node){
const required_resources = JSON.parse(node['required_resources']);
let hostname = document.getElementById('id_hostname');
+ let image = document.getElementById('id_image');
let cnt = 0
@@ -417,8 +418,10 @@ class MultipleSelectFilterWidget {
cnt += required_resources[resource];
}
- if (cnt > 1)
+ if (cnt > 1) {
hostname.readOnly = true;
+ image.disabled = true;
+ }
this.updateAvailibility();
}
@@ -426,12 +429,14 @@ class MultipleSelectFilterWidget {
releaseResource(node){
const required_resources = JSON.parse(node['required_resources']);
let hostname = document.getElementById('id_hostname');
+ let image = document.getElementById('id_image');
for(let resource in required_resources){
this.available_resources[resource] += required_resources[resource];
}
hostname.readOnly = false;
+ image.readOnly = false;
this.updateAvailibility();
}