aboutsummaryrefslogtreecommitdiffstats
path: root/src/booking
diff options
context:
space:
mode:
Diffstat (limited to 'src/booking')
-rw-r--r--src/booking/forms.py20
-rw-r--r--src/booking/lib.py2
-rw-r--r--src/booking/quick_deployer.py5
-rw-r--r--src/booking/views.py3
4 files changed, 25 insertions, 5 deletions
diff --git a/src/booking/forms.py b/src/booking/forms.py
index 2a8784f..cbc3407 100644
--- a/src/booking/forms.py
+++ b/src/booking/forms.py
@@ -21,7 +21,7 @@ from booking.lib import get_user_items, get_user_field_opts
class QuickBookingForm(forms.Form):
purpose = forms.CharField(max_length=1000)
project = forms.CharField(max_length=400)
- hostname = forms.CharField(max_length=400)
+ hostname = forms.CharField(required=False, max_length=400)
installer = forms.ModelChoiceField(queryset=Installer.objects.all(), required=False)
scenario = forms.ModelChoiceField(queryset=Scenario.objects.all(), required=False)
@@ -35,12 +35,20 @@ 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),
+ queryset=UserProfile.objects.filter(public_user=True).select_related('user').exclude(user=user),
items=get_user_items(exclude=user),
required=False,
**get_user_field_opts()
@@ -59,6 +67,14 @@ class QuickBookingForm(forms.Form):
self.fields['filter_field'] = MultipleSelectFilterField(widget=MultipleSelectFilterWidget(**lab_data))
+ 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': hostname_help_text,
+ 'data-placement': 'top',
+ 'data-container': 'body'
+ })
+
def build_user_list(self):
"""
Build list of UserProfiles.
diff --git a/src/booking/lib.py b/src/booking/lib.py
index 8132c75..7a4c261 100644
--- a/src/booking/lib.py
+++ b/src/booking/lib.py
@@ -23,7 +23,7 @@ def get_user_field_opts():
def get_user_items(exclude=None):
- qs = UserProfile.objects.select_related('user').exclude(user=exclude)
+ qs = UserProfile.objects.filter(public_user=True).select_related('user').exclude(user=exclude)
items = {}
for up in qs:
item = {
diff --git a/src/booking/quick_deployer.py b/src/booking/quick_deployer.py
index 8b3af6c..0a3bfc6 100644
--- a/src/booking/quick_deployer.py
+++ b/src/booking/quick_deployer.py
@@ -111,7 +111,8 @@ def update_template(old_template, image, hostname, user):
profile=old_config.profile,
image=image_to_set,
template=template,
- is_head_node=old_config.is_head_node
+ is_head_node=old_config.is_head_node,
+ name=hostname if len(old_template.getConfigs()) == 1 else old_config.name
)
for old_iface_config in old_config.interface_configs.all():
@@ -204,7 +205,7 @@ def create_from_form(form, request):
purpose_field = form.cleaned_data['purpose']
project_field = form.cleaned_data['project']
users_field = form.cleaned_data['users']
- hostname = form.cleaned_data['hostname']
+ hostname = 'opnfv_host' if not form.cleaned_data['hostname'] else form.cleaned_data['hostname']
length = form.cleaned_data['length']
image = form.cleaned_data['image']
diff --git a/src/booking/views.py b/src/booking/views.py
index c41a7d6..66cb594 100644
--- a/src/booking/views.py
+++ b/src/booking/views.py
@@ -63,9 +63,12 @@ def quick_create(request):
return redirect(reverse('booking:booking_detail', kwargs={'booking_id': booking.id}))
except Exception as e:
messages.error(request, "Whoops, an error occurred: " + str(e))
+ context.update(drop_filter(request.user))
return render(request, 'booking/quick_deploy.html', context)
else:
messages.error(request, "Looks like the form didn't validate. Check that you entered everything correctly")
+ context['status'] = 'false'
+ context.update(drop_filter(request.user))
return render(request, 'booking/quick_deploy.html', context)