detail.html 7.12 KB
Newer Older
1 2 3 4
{% extends "dashboard/base.html" %}
{% load staticfiles %}
{% load i18n %}
{% load render_table from django_tables2 %}
5
{% load arrowfilter %}
6
{% load sizefieldtags %}
7

8
{% block title-page %}{% trans "Request" %}{% endblock %}
9 10 11 12 13 14 15

{% block content %}

<div class="row">
  <div class="col-md-12">
    <div class="panel panel-default">
      <div class="panel-heading">
16 17 18 19 20
        {% if request.user.is_superuser %}
          <a href="{% url "request.views.request-list" %}" class="btn btn-default btn-xs pull-right">
            {% trans "Back" %}
          </a>
        {% endif %}
21
        <h3 class="no-margin">
22
          <i class="fa fa-{{ object.get_request_icon }}"></i>
23
          {{ object.get_readable_type|capfirst }}
24 25 26 27
        </h3>
      </div>
      <div class="panel-body">
        <div class="label label-{{ object.get_effect }} pull-right" style="font-size: 1.5em; margin-top: 10px;">
28
          <i class="fa fa-{{ object.get_status_icon }}"></i>
29 30 31 32
          {{ object.get_readable_status|upper }}
        </div>
        <p>
          <img src="{{ object.user.profile.get_avatar_url }}" width="50" height="50"/>
33
          <a href="{{ object.user.profile.get_absolute_url }}">
34 35 36 37
            {{ object.user.profile.get_display_name }}
          </a>
        </p>
        <p>
38
          <pre>{{ object.message }}</pre>
39 40
        </p>
        <hr />
41 42 43
        <div class="pull-right">
          <strong>{% trans "Submitted" %}:</strong> {{ object.created }}
        </div>
44 45 46 47 48 49
        {% if object.type == "lease" %}
          <dl>
            <dt>{% trans "VM name" %}</dt>
            <dd><a href="{{ action.instance.get_absolute_url }}">{{ action.instance.name }}</a></dd>
            <dt>{% trans "VM description" %}</dt>
            <dd>{{ action.instance.description }}</dd>
50
            <dt>{% trans "Current lease" %}</dt>
51
            <dd>{{ action.instance.lease }}</dd>
52
            <dt>{% trans "Requested lease" %}</dt>
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
            <dd>{{ action.lease_type.lease }}</dd>
          </dl>
        {% elif object.type == "template" %}
          <dl>
            <dt>
              {% trans "Template type" %}:
              <span style="font-weight: normal;">{{ action.template_type.name }}</span>
            </dt>
            <dd>
              <ul>
                {% for t in action.template_type.templates.all %}
                  <li><a href="{{ t.get_absolute_url }}">{{ t }}</a></li>
                {% endfor %}
              </ul>
            </dd>
            <dt>{% trans "Level" %}<dt>
            <dd>{{ action.get_readable_level }}</dd>
          </dl>
        {% elif object.type == "resource" %}
72 73 74 75 76 77 78 79 80
          {% if not is_acceptable %}
            <div class="alert alert-warning">
              {% blocktrans %}
              To change the resources the virtual machine must be in one of the following states:
              STOPPED, PENDING, RUNNING. If the virtual machine is running it will be
              automatically stopped when accepting the request.
              {% endblocktrans %}
            </div>
          {% endif %}
81 82 83
          <dl>
            <dt>{% trans "VM name" %}</dt>
            <dd><a href="{{ action.instance.get_absolute_url }}">{{ action.instance.name }}</a></dd>
84 85 86 87 88
            <dt>{% trans "Status" %}</dt>
            <dd>
              <i class="fa {{ action.instance.get_status_icon }}"></i>
              {{ action.instance.get_status_display|upper }}
            </dd>
89
            <dt>{% trans "VM description" %}</dt>
90
            <dd>{{ action.instance.description|default:"-" }}</dd>
91 92 93 94 95 96 97 98 99 100
            <dt>
              {% trans "Priority" %}
              <span class="text-muted" style="font-weight: normal;">{% trans "(old values in parentheses)" %}</span>
            </dt>
            <dd>{{ action.priority }} ({{ action.instance.priority }})</dd>
            <dt>{% trans "Number of cores" %}</dt>
            <dd>{{ action.num_cores }} ({{ action.instance.num_cores }})</dd>
            <dt>{% trans "Ram size" %}</dt>
            <dd>{{ action.ram_size }} ({{ action.instance.ram_size }}) MiB</dd>
          </dl>
101
        {% elif object.type == "resize" %}
102 103 104 105 106
          {% if not is_acceptable %}
            <div class="alert alert-warning">
              {% trans "To resize the disk the virtual machine must be in RUNNING state." %}
            </div>
          {% endif %}
107 108 109
          <dl>
            <dt>{% trans "VM name" %}</dt>
            <dd><a href="{{ action.instance.get_absolute_url }}">{{ action.instance.name }}</a></dd>
110 111 112 113 114
            <dt>{% trans "Status" %}</dt>
            <dd>
              <i class="fa {{ action.instance.get_status_icon }}"></i>
              {{ action.instance.get_status_display|upper }}
            </dd>
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
            <dt>{% trans "VM description" %}</dt>
            <dd>{{ action.instance.description|default:"-" }}</dd>
            <dt>{% trans "Disk" %}</dt>
            <dd>
            {% if request.user.is_superuser %}
              <a href="{{ action.disk.get_absolute_url }}">
              {{ action.disk.name }} (#{{ action.disk.id}})
              </a>
            {% else %}
              {{ action.disk.name }} (#{{ action.disk.id}})</dd>
            {% endif %}
            </dd>
            <dt>{% trans "Current size" %}</dt>
            <dd>{{ action.disk.size|filesize}} ({{ action.disk.size }} bytes)</dd>
            <dt>{% trans "Requested size" %}</dt>
            <dd>{{ action.size|filesize}} ({{ action.size }} bytes)</dd>
          </dl>
132
        {% else %}
133
          Are you adding a new action type?
134 135
        {% endif %}

136
        {% if object.status == "PENDING" and request.user.is_superuser %}
137 138
          <hr />

139 140
          <div class="pull-right" id="request-buttons">
            <form method="POST">
141
              {% csrf_token %}
142 143 144
              <p>
              <textarea class="form-control" placeholder="{% trans "Reason (sent to the user if the request is declined)" %}" name="reason"></textarea>
              </p>
145 146
              <button class="btn btn-danger" type="submit">
                <i class="fa fa-thumbs-down"></i>
147
                {% trans "Decline" %}
148 149
              </button>
            </form>
150
            {% if not is_acceptable %}
151 152
              {% trans "You can't accept this request because of the VM's state." %}
            {% else %}
153 154 155 156 157 158 159 160
              <form method="POST">
                {% csrf_token %}
                <input type="hidden" name="accept" value="1"/>
                <button class="btn btn-success">
                  <i class="fa fa-thumbs-up"></i>
                  {% trans "Accept" %}
                </button>
              </form>
161
            {% endif %}
162
          </div>
163 164
        {% endif %}
        {% if object.status != "PENDING" %}
165
          <div class="text-right">
166 167
            {% blocktrans with closed=object.modified|arrowfilter:LANGUAGE_CODE user=object.closed_by.profile.get_display_name %}
            Closed {{ closed }} by <a href="{{ user.profile.get_absolute_url }}">{{ user }}</a>
168
            {% endblocktrans %}
169 170 171 172 173
            {% if object.status == "DECLINED" %}
              <p>
                <strong>{% trans "Reason" %}:</strong> {{ object.reason }}
              </p>
            {% endif %}
174
          </div>
175
        {% endif %}
176 177 178 179 180
      </div><!-- .panel-body -->
    </div>
  </div>
</div>
{% endblock %}