From 646bdbbe0eed5261998e8f7fbfa25eeb90afa76b Mon Sep 17 00:00:00 2001 From: Jan Krcmar Date: Wed, 20 Jan 2016 15:40:09 +0100 Subject: [PATCH] Added is_template attribute to instances. If true, instance cannot be started. --- instances/models.py | 1 + instances/templates/instance.html | 31 ++++++++++++++++++++++++++++-- instances/templates/instances.html | 2 +- instances/views.py | 8 ++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/instances/models.py b/instances/models.py index 4345cc1..bf2a1c4 100644 --- a/instances/models.py +++ b/instances/models.py @@ -6,6 +6,7 @@ class Instance(models.Model): compute = models.ForeignKey(Compute) name = models.CharField(max_length=20) uuid = models.CharField(max_length=36) + is_template = models.BooleanField(default=False) def __unicode__(self): return self.name diff --git a/instances/templates/instance.html b/instances/templates/instance.html index c33082e..42ba74c 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -204,7 +204,12 @@

{% trans "Click on Boot button to start this instance." %}

{% csrf_token %} - + {% if instance.is_template %} +

{% trans "Template instance cannot be started." %}

+ + {% else %} + + {% endif %}
@@ -511,6 +516,11 @@ {% trans "XML" %} +
  • + + {% trans "Template" %} + +
  • {% endif %} @@ -684,6 +694,23 @@
    +
    +

    {% trans "Is this instance template?" %}

    +
    {% csrf_token %} +
    + +
    + +
    +
    + {% ifequal status 5 %} + + {% else %} + + {% endifequal %} +
    +
    +

    {% trans "Create a clone" %}

    {% csrf_token %} @@ -1149,7 +1176,7 @@ } }); } - if (~$.inArray(hash, ['#media', '#network', '#clone', '#autostart', '#xmledit', '#vncsettings', '#migrate'])) { + if (~$.inArray(hash, ['#media', '#network', '#clone', '#autostart', '#xmledit', '#vncsettings', '#migrate', '#template'])) { var btnsect = $('#navbtn>li>a'); $(btnsect).each(function () { if ($(this).attr('href') === '#settings') { diff --git a/instances/templates/instances.html b/instances/templates/instances.html index 144a5cd..b279d40 100644 --- a/instances/templates/instances.html +++ b/instances/templates/instances.html @@ -69,7 +69,7 @@ {% ifequal info.status 5 %} -