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

{% block title-page %}{% trans "Edit template" %}{% endblock %}

8 9 10
{% block content %}

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

26
  <div class="col-md-5">
27 28
    <div class="panel panel-default">
      <div class="panel-heading">
29
        <h4 class="no-margin"><i class="fa fa-group"></i> {% trans "Manage access"  %}</h4>
30 31 32
      </div>
      <div class="panel-body">
        <form action="{% url "dashboard.views.template-acl" pk=object.pk %}" method="post">{% csrf_token %}
33 34 35 36 37 38
          <table class="table table-striped table-with-form-fields" id="template-access-table">
            <thead>
              <tr>
                <th></th>
                <th>{% trans "Who" %}</th>
                <th>{% trans "What" %}</th>
39
                <th><i class="fa fa-times"></i></th>
40 41
              </tr>
            </thead>
42
            <tbody>
43 44 45
              {% for i in acl.users %}
              <tr>
                <td>
46
                  <i class="fa fa-user"></i>
47 48 49 50 51 52 53 54
                </td>
                <td>
                  <a href="{% url "dashboard.views.profile" username=i.user.username %}"
                    title="{{ i.user.username }}">
                    {% include "dashboard/_display-name.html" with user=i.user show_org=True %}
                  </a>
                </td>
                <td>
55
                  <select class="form-control" name="perm-u-{{i.user.id}}"{% if i.level not in acl.allowed_levels %} disabled{% endif %}>
56
                    {% for id, name in acl.levels %}
57 58 59
                    <option{%if id = i.level%} selected="selected"{%endif%}
                    {% if id not in acl.allowed_levels %} disabled{% endif %}
                     value="{{id}}">{{name}}</option>
60 61 62 63 64 65 66 67 68 69
                    {% endfor %}
                  </select>
                </td>
                <td>
                  <input type="checkbox" name="remove-u-{{i.user.id}}" title="{% trans "Remove" %}"/>
                </td>
              </tr>
              {% endfor %}
              {% for i in acl.groups %}
              <tr>
70
                <td><i class="fa fa-group"></i></td>
71 72 73 74 75 76
                <td>
                  <a href="{% url "dashboard.views.group-detail" pk=i.group.pk %}">
                    {{i.group}}
                  </a>
                </td>
                <td>
77
                  <select class="form-control" name="perm-g-{{i.group.id}}{% if i.level not in acl.allowed_levels %} disabled{% endif %}">
78
                    {% for id, name in acl.levels %}
79 80 81
                    <option{%if id = i.level%} selected="selected"{%endif%}
                    {% if id not in acl.allowed_levels %} disabled{% endif %}
                     value="{{id}}">{{name}}</option>
82 83 84 85 86 87 88 89
                    {% endfor %}
                  </select>
                </td>
                <td>
                  <input type="checkbox" name="remove-g-{{i.group.id}}" title="{% trans "Remove" %}"/>
                </td>
              </tr>
              {% endfor %}
90
              <tr><td><i class="fa fa-plus"></i></td>
91 92 93 94
                  <td>{{aclform.name }}</td>
                  <td><select class="form-control" name="level">
                          {% for id, name in acl.levels %}
                          {% if id in acl.allowed_levels %}
95
                          <option value="{{id}}">{{name}}</option>
96
                          {% endif %}
97 98 99 100
                          {% endfor %}
                  </select></td><td></td>
              </tr>
            </tbody>
101 102
          </table>
          <div class="form-actions">
103
            <button type="submit" class="btn btn-success">{% trans "Save" %}</button>
104 105 106 107
          </div>
        </form>
      </div>
    </div>
108 109


110 111
    <div class="panel panel-default">
      <div class="panel-heading">
112
        <h4 class="no-margin"><i class="fa fa-file"></i> {% trans "Disk list" %}</h4>
113 114
      </div>
      <div class="panel-body">
115 116 117 118
        <ul class="template-disk-list">
        {% if not disks %}
          {% trans "No disks are added!" %}
        {% endif %}
119 120 121 122 123 124 125 126
        {% for d in disks %}
          <li>
            {% include "dashboard/_disk-list-element.html" %}
          </li>
        {% endfor %}
        </ul>
      </div>
    </div>
127 128
  </div><!-- .col-md-4 -->
</div><!-- .row -->
129

130

131 132 133 134 135 136 137 138
<style>
  fieldset {
    margin-top: 40px;
  }
  fieldset legend {
    font-weight: bold;
  }
</style>
139 140 141 142 143 144 145 146
{% endblock %}

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

148
  <script src="{{ STATIC_URL }}dashboard/disk-list.js"></script>
149
{% endblock %}