template-edit.html 5.05 KB
Newer Older
1
{% extends "dashboard/base.html" %}
2
{% load staticfiles %}
3
{% load i18n %}
4
{% load sizefieldtags %}
5
{% load crispy_forms_tags %}
6

7
{% block title-page %}{{ form.name.value }} | {% trans "template" %}{% endblock %}
8

9 10 11
{% block content %}

<div class="row">
12
  <div class="col-md-7">
13 14
    <div class="panel panel-default">
      <div class="panel-heading">
15 16 17
        <a class="pull-right btn btn-default btn-xs" href="{% url "dashboard.views.template-list" %}">
          {% trans "Back" %}
        </a>
18
        <h3 class="no-margin"><i class="fa fa-puzzle-piece"></i> {% trans "Edit template" %}</h3>
19 20
      </div>
      <div class="panel-body">
21
        <form action="" method="POST">
22 23 24
        {% with form=form %}
          {% include "display-form-errors.html" %}
        {% endwith %}
25 26 27 28

        {% csrf_token %}

        {{ form.name|as_crispy_field }}
29 30 31 32 33 34 35 36 37

        <strong>{% trans "Parent template" %}:</strong>
        {% if parent %}
        <a href="{% url "dashboard.views.template-detail" pk=parent.pk %}">
          {{ parent.name }}
        </a>
        {% else %}
          -
        {% endif %}
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

        <fieldset class="resources-sliders">
          <legend>{% trans "Resource configuration" %}</legend>
          {% include "dashboard/_resources-sliders.html" with field_priority=form.priority field_num_cores=form.num_cores field_ram_size=form.ram_size %}
          {{ form.max_ram_size|as_crispy_field }}
        </fieldset>

        <fieldset>
          <legend>{% trans "Virtual machine settings" %}</legend>
        {{ form.arch|as_crispy_field }}
        {{ form.access_method|as_crispy_field }}
        {{ form.boot_menu|as_crispy_field }}
        {{ form.raw_data|as_crispy_field }}
        {{ form.req_traits|as_crispy_field }}
        {{ form.description|as_crispy_field }}
        {{ form.system|as_crispy_field }}
54
        {{ form.has_agent|as_crispy_field }}
55 56 57 58 59 60 61 62 63 64 65
        </fieldset>
        <fieldset>
          <legend>{% trans "External resources" %}</legend>
        {{ form.networks|as_crispy_field }}
        {{ form.lease|as_crispy_field }}

        {{ form.tags|as_crispy_field }}
        </fieldset>

        <input type="submit" value="{% trans "Save changes" %}" class="btn btn-primary">
        </form>
66 67 68
      </div>
    </div>
  </div>
69

70
  <div class="col-md-5">
71 72 73 74 75 76 77 78 79 80 81 82
    {% if is_owner %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <a href="{% url "dashboard.views.template-delete" pk=object.pk %}" 
         class="btn btn-xs btn-danger pull-right">
          {% trans "Delete" %}
        </a>
        <h4 class="no-margin"><i class="fa fa-times"></i> {% trans "Delete template"  %}</h4>
      </div>
    </div>
    {% endif %}

83 84
    <div class="panel panel-default">
      <div class="panel-heading">
85 86 87 88 89 90
        <h4 class="no-margin"><i class="fa fa-user"></i> {% trans "Owner"  %}</h4>
      </div>
      <div class="panel-body">
        {% if user == object.owner %}
        {% blocktrans %}You are the current owner of this template.{% endblocktrans %}
        {% else %}
91
        {% url "dashboard.views.profile" username=object.owner.username as url %}
92
        {% blocktrans with owner=object.owner name=object.owner.get_full_name%}
93
          The current owner of this template is <a href="{{url}}">{{name}} ({{owner}})</a>.
94 95 96 97 98 99 100 101 102 103 104
        {% endblocktrans %}
        {% endif %}
        {% if user == object.owner or user.is_superuser %}
        <a href="{% url "dashboard.views.template-transfer-ownership" object.pk %}"
           class="btn btn-link tx-tpl-ownership">{% trans "Transfer ownership..." %}</a>
        {% endif %}
      </div>
    </div>

    <div class="panel panel-default">
      <div class="panel-heading">
105
        <h4 class="no-margin"><i class="fa fa-group"></i> {% trans "Manage access"  %}</h4>
106 107
      </div>
      <div class="panel-body">
108
        {% include "dashboard/_manage_access.html" with table_id="template-access-table" %}
109 110
      </div>
    </div>
111 112


113 114
    <div class="panel panel-default">
      <div class="panel-heading">
115
        <h4 class="no-margin"><i class="fa fa-file"></i> {% trans "Disk list" %}</h4>
116 117
      </div>
      <div class="panel-body">
118 119 120 121
        <ul class="template-disk-list">
        {% if not disks %}
          {% trans "No disks are added!" %}
        {% endif %}
122 123
        {% for d in disks %}
          <li>
124 125 126 127 128 129 130
            <i class="fa fa-file"></i>
            {{ d.name }} (#{{ d.id }}) -
            <a href="{% url "dashboard.views.disk-remove" pk=d.pk %}?next={{ request.path }}"
              data-disk-pk="{{ d.pk }}" class="btn btn-xs btn-danger pull-right disk-remove"
              {% if not long_remove %}title="{% trans "Remove" %}"{% endif %}>
              <i class="fa fa-times"></i>{% if long_remove %} {% trans "Remove" %}{% endif %}
            </a>
131 132 133 134 135
          </li>
        {% endfor %}
        </ul>
      </div>
    </div>
136 137
  </div><!-- .col-md-4 -->
</div><!-- .row -->
138

139

140 141 142 143 144 145 146 147
<style>
  fieldset {
    margin-top: 40px;
  }
  fieldset legend {
    font-weight: bold;
  }
</style>
148 149 150 151 152 153 154 155
{% endblock %}

{% block extra_js %}
  <script>
    $(function() {
      $("#hint_id_num_cores, #hint_id_priority, #hint_id_ram_size").hide();
    });
  </script>
156
{% endblock %}