diff options
Diffstat (limited to 'src/booking')
-rw-r--r-- | src/booking/forms.py | 14 | ||||
-rw-r--r-- | src/booking/quick_deployer.py | 2 | ||||
-rw-r--r-- | src/booking/views.py | 3 |
3 files changed, 8 insertions, 11 deletions
diff --git a/src/booking/forms.py b/src/booking/forms.py index 7ba5af0..9349ac1 100644 --- a/src/booking/forms.py +++ b/src/booking/forms.py @@ -8,7 +8,6 @@ ############################################################################## import django.forms as forms from django.forms.widgets import NumberInput -from django.db.models import Q from workflow.forms import ( SearchableSelectMultipleWidget, @@ -22,7 +21,6 @@ from resource_inventory.models import Image, Installer, Scenario class QuickBookingForm(forms.Form): purpose = forms.CharField(max_length=1000) project = forms.CharField(max_length=400) - image = forms.ModelChoiceField(queryset=Image.objects.all()) hostname = forms.CharField(max_length=400) installer = forms.ModelChoiceField(queryset=Installer.objects.all(), required=False) @@ -40,14 +38,14 @@ class QuickBookingForm(forms.Form): elif data and "users" in data: chosen_users = data.getlist("users") - if user: - self.image = forms.ModelChoiceField(queryset=Image.objects.filter( - Q(public=True) | Q(owner=user)), required=False) - else: - self.image = forms.ModelChoiceField(queryset=Image.objects.all(), required=False) - super(QuickBookingForm, self).__init__(data=data, **kwargs) + self.fields["image"] = forms.ModelChoiceField( + queryset=Image.objects.difference( + Image.objects.filter(public=False).difference(Image.objects.filter(owner=user)) + ) + ) + self.fields['users'] = forms.CharField( widget=SearchableSelectMultipleWidget( attrs=self.build_search_widget_attrs(chosen_users, default_user=default_user) diff --git a/src/booking/quick_deployer.py b/src/booking/quick_deployer.py index f8dc9ff..cc593fa 100644 --- a/src/booking/quick_deployer.py +++ b/src/booking/quick_deployer.py @@ -119,7 +119,7 @@ def check_available_matching_host(lab, hostprofile): available_host_types = ResourceManager.getInstance().getAvailableHostTypes(lab) if hostprofile not in available_host_types: # TODO: handle deleting generic resource in this instance along with grb - raise HostNotAvailable("Could not book selected host due to changed availability. Try again later") + raise HostNotAvailable('Requested host type is not available. Please try again later. Host availability can be viewed in the "Hosts" tab to the left.') hostset = Host.objects.filter(lab=lab, profile=hostprofile).filter(booked=False).filter(working=True) if not hostset.exists(): diff --git a/src/booking/views.py b/src/booking/views.py index 1e14b8e..8211a0c 100644 --- a/src/booking/views.py +++ b/src/booking/views.py @@ -62,8 +62,7 @@ def quick_create(request): try: create_from_form(form, request) except Exception as e: - messages.error(request, "Whoops, looks like an error occurred. " - "Let the admins know that you got the following message: " + str(e)) + messages.error(request, "Whoops, an error occurred: " + str(e)) return render(request, 'workflow/exit_redirect.html', context) messages.success(request, "We've processed your request. " |