detail.html 5.21 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

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

{% block content %}

<div class="row">
  <div class="col-md-12">
    <div class="panel panel-default">
      <div class="panel-heading">
15 16 17 18 19
        {% if request.user.is_superuser %}
          <a href="{% url "request.views.request-list" %}" class="btn btn-default btn-xs pull-right">
            {% trans "Back" %}
          </a>
        {% endif %}
20
        <h3 class="no-margin">
21
          <i class="fa fa-{{ object.get_request_icon }}"></i>
22
          {{ object.get_readable_type|capfirst }}
23 24 25 26
        </h3>
      </div>
      <div class="panel-body">
        <div class="label label-{{ object.get_effect }} pull-right" style="font-size: 1.5em; margin-top: 10px;">
27
          <i class="fa fa-{{ object.get_status_icon }}"></i>
28 29 30 31
          {{ object.get_readable_status|upper }}
        </div>
        <p>
          <img src="{{ object.user.profile.get_avatar_url }}" width="50" height="50"/>
32
          <a href="{{ object.user.profile.get_absolute_url }}">
33 34 35 36
            {{ object.user.profile.get_display_name }}
          </a>
        </p>
        <p>
37
          <pre>{{ object.message }}</pre>
38 39 40 41 42 43 44 45
        </p>
        <hr />
        {% 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>
46
            <dt>{% trans "Current lease" %}</dt>
47
            <dd>{{ action.instance.lease }}</dd>
48
            <dt>{% trans "Requested lease" %}</dt>
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
            <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" %}
          <dl>
            <dt>{% trans "VM name" %}</dt>
            <dd><a href="{{ action.instance.get_absolute_url }}">{{ action.instance.name }}</a></dd>
71 72 73 74 75
            <dt>{% trans "Status" %}</dt>
            <dd>
              <i class="fa {{ action.instance.get_status_icon }}"></i>
              {{ action.instance.get_status_display|upper }}
            </dd>
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
            <dt>{% trans "VM description" %}</dt>
            <dd>{{ action.instance.description }}</dd>
            <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>
        {% else %}
          hacks!!!
        {% endif %}

92
        {% if object.status == "PENDING" and request.user.is_superuser %}
93 94
          <hr />

95 96
          <div class="pull-right" id="request-buttons">
            <form method="POST">
97
              {% csrf_token %}
98 99 100
              <p>
              <textarea class="form-control" placeholder="{% trans "Reason (sent to the user if the request is declined)" %}" name="reason"></textarea>
              </p>
101 102
              <button class="btn btn-danger" type="submit">
                <i class="fa fa-thumbs-down"></i>
103
                {% trans "Decline" %}
104 105
              </button>
            </form>
106 107 108
            {% if object.type == "resource" and action.instance.status not in accept_states %}
              {% trans "You can't accept this request because of the VM's state." %}
            {% else %}
109 110 111 112 113 114 115 116
              <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>
117
            {% endif %}
118
          </div>
119 120
        {% endif %}
        {% if object.status != "PENDING" %}
121
          <div class="text-right">
122 123
            {% 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>
124
            {% endblocktrans %}
125 126 127 128 129
            {% if object.status == "DECLINED" %}
              <p>
                <strong>{% trans "Reason" %}:</strong> {{ object.reason }}
              </p>
            {% endif %}
130
          </div>
131
        {% endif %}
132 133 134 135 136
      </div><!-- .panel-body -->
    </div>
  </div>
</div>
{% endblock %}