Commit fa0bd815 by Kálmán Viktor

dashboard: warn the user to select something in template choose

parent 0ae68ec4
...@@ -46,6 +46,16 @@ $(function () { ...@@ -46,6 +46,16 @@ $(function () {
$('#create-modal').on('hidden.bs.modal', function() { $('#create-modal').on('hidden.bs.modal', function() {
$('#create-modal').remove(); $('#create-modal').remove();
}); });
// check if user selected anything
$("#template-choose-next-button").click(function() {
var radio = $('input[type="radio"]:checked', "#template-choose-form").val();
if(!radio) {
$("#template-choose-alert").addClass("alert-warning")
.text(gettext("Select an option to proceed!"));
return false;
}
return true;
});
} }
}); });
return false; return false;
......
{% load i18n %} {% load i18n %}
<div class="alert alert-info"> <div class="alert alert-info" id="template-choose-alert">
{% trans "Customize an existing template or create a brand new one from scratch!" %} {% trans "Customize an existing template or create a brand new one from scratch!" %}
</div> </div>
<form action="{% url "dashboard.views.template-choose" %}" method="POST"> <form action="{% url "dashboard.views.template-choose" %}" method="POST"
id="template-choose-form">
{% csrf_token %} {% csrf_token %}
<div class="template-choose-list"> <div class="template-choose-list">
{% for t in templates %} {% for t in templates %}
...@@ -19,7 +20,7 @@ ...@@ -19,7 +20,7 @@
<input type="radio" name="parent" value="base_vm"/> <input type="radio" name="parent" value="base_vm"/>
{% trans "Create a new base VM without disk" %} {% trans "Create a new base VM without disk" %}
</div> </div>
<button type="submit" class="btn btn-success pull-right">{% trans "Next" %}</button> <button type="submit" id="template-choose-next-button" class="btn btn-success pull-right">{% trans "Next" %}</button>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
</form> </form>
......
...@@ -853,6 +853,9 @@ class TemplateChoose(TemplateView): ...@@ -853,6 +853,9 @@ class TemplateChoose(TemplateView):
template = request.POST.get("parent") template = request.POST.get("parent")
if template == "base_vm": if template == "base_vm":
return redirect(reverse("dashboard.views.template-create")) return redirect(reverse("dashboard.views.template-create"))
elif template is None:
messages.warning(request, _("Select an option to proceed!"))
return redirect(reverse("dashboard.views.template-choose"))
else: else:
template = get_object_or_404(InstanceTemplate, pk=template) template = get_object_or_404(InstanceTemplate, pk=template)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment