Skip to content

Commit

Permalink
replace deprecated ifequal/ifnotequal with if
Browse files Browse the repository at this point in the history
  • Loading branch information
catborise committed Jun 4, 2020
1 parent e46bb99 commit 6a0d04d
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 74 deletions.
16 changes: 8 additions & 8 deletions computes/templates/computes.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h5 class="my-0 card-title">
<h5 class="modal-title">{% trans "Edit connection" %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
{% ifequal compute.type 1 %}
{% if compute.type == 1 %}
<form method="post" role="form" aria-label="Edit tcp host form">{% csrf_token %}
<div class="modal-body">
<div class="form-group row">
Expand Down Expand Up @@ -105,8 +105,8 @@ <h5 class="modal-title">{% trans "Edit connection" %}</h5>
</button>
</div>
</form>
{% endifequal %}
{% ifequal compute.type 2 %}
{% endif %}
{% if compute.type == 2 %}
<form method="post" role="form" aria-label="Edit ssh host form">{% csrf_token %}
<div class="modal-body">
<p class="modal-body">{% trans "Need create ssh <a href='https://github.com/retspen/webvirtmgr/wiki/Setup-SSH-Authorization'>authorization key</a>. If you have another SSH port on your server, you can add IP:PORT like '192.168.1.1:2222'." %}</p>
Expand Down Expand Up @@ -149,8 +149,8 @@ <h5 class="modal-title">{% trans "Edit connection" %}</h5>
</button>
</div>
</form>
{% endifequal %}
{% ifequal compute.type 3 %}
{% endif %}
{% if compute.type == 3 %}
<form method="post" role="form" aria-label="Edit tls host form">{% csrf_token %}
<div class="modal-body">
<div class="form-group row">
Expand Down Expand Up @@ -197,8 +197,8 @@ <h5 class="modal-title">{% trans "Edit connection" %}</h5>
</button>
</div>
</form>
{% endifequal %}
{% ifequal compute.type 4 %}
{% endif %}
{% if compute.type == 4 %}
<form method="post" role="form" aria-label="Edit/delete host form">{% csrf_token %}
<div class="modal-body">
<div class="form-group row">
Expand Down Expand Up @@ -226,7 +226,7 @@ <h5 class="modal-title">{% trans "Edit connection" %}</h5>
</button>
</div>
</form>
{% endifequal %}
{% endif %}
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Expand Down
6 changes: 3 additions & 3 deletions create/templates/create_instance_w2.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h5 class="modal-title">{% trans "Create Virtual Machine" %} ({{ flavor.label }}
{% endfor %}
</optgroup>
{% else %}
<option value="{{ mode }}" {% ifequal mode default_cpu_mode %}selected {% endifequal %}>
<option value="{{ mode }}" {% if mode == default_cpu_mode %}selected {% endif %}>
{% trans mode %}
</option>
{% endif %}
Expand Down Expand Up @@ -343,7 +343,7 @@ <h5 class="modal-title">{% trans "Create Virtual Machine" %} ({{ flavor.label }}
{% endfor %}
</optgroup>
{% else %}
<option value="{{ mode }}" {% ifequal mode default_cpu_mode %}selected {% endifequal %}>
<option value="{{ mode }}" {% if mode == default_cpu_mode %}selected {% endif %}>
{% trans mode %}
</option>
{% endif %}
Expand Down Expand Up @@ -555,7 +555,7 @@ <h5 class="modal-title">{% trans "Create Virtual Machine" %} ({{ flavor.label }}
{% endfor %}
</optgroup>
{% else %}
<option value="{{ mode }}" {% ifequal mode default_cpu_mode %}selected {% endifequal %}>
<option value="{{ mode }}" {% if mode == default_cpu_mode %}selected{% endif %}>
{% trans mode %}
</option>
{% endif %}
Expand Down
20 changes: 10 additions & 10 deletions instances/templates/allinstances.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ <h2 class="page-header">{% trans "Instances" %}</h2>
</div>
</div>
{% else %}
{% ifequal view_style "nongrouped" %}
{% if view_style == "nongrouped" %}
{% include 'allinstances_index_nongrouped.html' %}
{% endifequal %}
{% ifequal view_style "grouped" %}
{% endif %}
{% if view_style == "grouped" %}
{% include 'allinstances_index_grouped.html' %}
{% endifequal %}
{% endif %}
{% endif %}
{% else %}
{% if not all_user_vms %}
Expand All @@ -64,15 +64,15 @@ <h2 class="page-header">{% trans "Instances" %}</h2>
{% for inst, vm in all_user_vms.items %}
<tr>
<td><a href="{% url 'instance' vm.compute_id vm.name %}">{{ vm.name }}</a><br><small><em>{{ vm.title }}</em></small></td>
<td>{% ifequal vm.status 1 %}
<td>{% if vm.status == 1 %}
<span class="text-success">{% trans "Active" %}</span>
{% endifequal %}
{% ifequal vm.status 5 %}
{% endif %}
{% if vm.status == 5 %}
<span class="text-danger">{% trans "Off" %}</span>
{% endifequal %}
{% ifequal vm.status 3 %}
{% endif %}
{% if vm.status == 3 %}
<span class="text-warning">{% trans "Suspend" %}</span>
{% endifequal %}
{% endif %}
</td>
<td>{{ vm.vcpu }}</td>
<td>{{ vm.memory }} {% trans "MB" %}</td>
Expand Down
12 changes: 6 additions & 6 deletions instances/templates/allinstances_index_grouped.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
</td>
<td class="d-none d-sm-table-cell"></td>
<td>
{% ifequal host.2 1 %}<span class="text-success">{% trans "Active" %}</span>{% endifequal %}
{% ifequal host.2 2 %}<span class="text-warning">{% trans "Not Active" %}</span>{% endifequal %}
{% ifequal host.2 3 %}<span class="text-danger">{% trans "Connection Failed" %}</span>{% endifequal %}
{% if host.2 == 1 %}<span class="text-success">{% trans "Active" %}</span>{% endif %}
{% if host.2 == 2 %}<span class="text-warning">{% trans "Not Active" %}</span>{% endif %}
{% if host.2 == 3 %}<span class="text-danger">{% trans "Connection Failed" %}</span>{% endif %}
</td>
<td class="d-none d-sm-table-cell text-center">{{ host.3 }}</td>
<td class="d-none d-sm-table-cell text-right">{{ host.4|filesizeformat }}</td>
Expand Down Expand Up @@ -53,9 +53,9 @@
</span>
</td>
<td>
{% ifequal vm.status 1 %}<span class="text-success">{% trans "Active" %}</span>{% endifequal %}
{% ifequal vm.status 5 %}<span class="text-danger">{% trans "Off" %}</span>{% endifequal %}
{% ifequal vm.status 3 %}<span class="text-warning">{% trans "Suspend" %}</span>{% endifequal %}
{% if vm.status == 1 %}<span class="text-success">{% trans "Active" %}</span>{% endif %}
{% if vm.status == 5 %}<span class="text-danger">{% trans "Off" %}</span>{% endif %}
{% if vm.status == 3 %}<span class="text-warning">{% trans "Suspend" %}</span>{% endif %}
</td>
<td class="d-none d-sm-table-cell text-center">{{ vm.vcpu }}</td>
<td class="d-none d-sm-table-cell text-right">{{ vm.memory |filesizeformat }}</td>
Expand Down
6 changes: 3 additions & 3 deletions instances/templates/allinstances_index_nongrouped.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<td><a href="{% url 'instance' host.0 inst %}">{{ inst }}</a><br><small><em>{{ info.title }}</em></small></td>
<td><a href="{% url 'overview' host.0 %}">{{ host.1 }}</a><br><small><em>{% if info.userinstances.count > 0 %}{{ info.userinstances.first_user.user.username }}{% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %}</em></small></td>
<td>
{% ifequal vm.status 1 %}<span class="text-success">{% trans "Active" %}</span>{% endifequal %}
{% ifequal vm.status 5 %}<span class="text-danger">{% trans "Off" %}</span>{% endifequal %}
{% ifequal vm.status 3 %}<span class="text-warning">{% trans "Suspend" %}</span>{% endifequal %}
{% if vm.status == 1 %}<span class="text-success">{% trans "Active" %}</span>{% endif %}
{% if vm.status == 5 %}<span class="text-danger">{% trans "Off" %}</span>{% endif %}
{% if vm.status == 3 %}<span class="text-warning">{% trans "Suspend" %}</span>{% endif %}
</td>
<td>{{ vm.vcpu }}</td>
<td>{{ vm.memory|filesizeformat }}</td>
Expand Down
12 changes: 6 additions & 6 deletions instances/templates/instance_actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<form action="" method="post" role="form" aria-label="Shortcut instance action form">{% csrf_token %}
<input type="hidden" name="name" value="{{ inst }}"/>
<input type="hidden" name="compute_id" value="{{ host.0 }}"/>
{% ifequal vm.status 5 %}
{% if vm.status == 5 %}
{% if vm.is_template %}
<button class="btn btn-sm btn-secondary" type="button" name="clone" title="{% trans "Clone" %}" onclick="goto_instance_clone({{ host.0 }}, '{{ inst }}');">
<span class="fa fa-clone"></span>
Expand All @@ -24,8 +24,8 @@
<button class="btn btn-sm btn-secondary disabled" title="{% trans "VNC Console" %}" disabled>
<span class="fa fa-eye"></span>
</button>
{% endifequal %}
{% ifequal vm.status 3 %}
{% endif %}
{% if vm.status == 3 %}
<button class="btn btn-sm btn-secondary" type="submit" name="resume" title="{% trans "Resume" %}">
<span class="fa fa-play"></span>
</button>
Expand All @@ -41,8 +41,8 @@
<button class="btn btn-sm btn-secondary disabled" title="{% trans "VNC Console" %}" disabled>
<span class="fa fa-eye"></span>
</button>
{% endifequal %}
{% ifequal vm.status 1 %}
{% endif %}
{% if vm.status == 1 %}
<button class="btn btn-sm btn-secondary disabled" title="{% trans "Power On" %}" disabled>
<span class="fa fa-play"></span>
</button>
Expand All @@ -58,5 +58,5 @@
<button class="btn btn-sm btn-secondary" type="button" onclick='open_console("{{ host.0 }}-{{ vm.uuid }}")' title="{% trans "Console" %}">
<span class="fa fa-eye"></span>
</button>
{% endifequal %}
{% endif %}
</form>
6 changes: 3 additions & 3 deletions instances/templates/instances.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ <h2 class="page-header">{{ compute.name }}</h2>
<td><a class="text-secondary" href="{% url 'instance' host.0 inst %}">{{ inst }}</a><br><small><em>{{ vm.title }}</em></small></td>
<td class="d-none d-md-table-cell"><small><em>{% if vm.userinstances.count > 0 %}{{ vm.userinstances.first_user.user.username }}{% if vm.userinstances.count > 1 %} (+{{ vm.userinstances.count|add:"-1" }}){% endif %}{% endif %}</em></small></td>
<td>
{% ifequal vm.status 1 %}<span class="text-success">{% trans "Active" %}</span>{% endifequal %}
{% ifequal vm.status 5 %}<span class="text-danger">{% trans "Off" %}</span>{% endifequal %}
{% ifequal vm.status 3 %}<span class="text-warning">{% trans "Suspend" %}</span>{% endifequal %}
{% if vm.status == 1 %}<span class="text-success">{% trans "Active" %}</span>{% endif %}
{% if vm.status == 5 %}<span class="text-danger">{% trans "Off" %}</span>{% endif %}
{% if vm.status == 3 %}<span class="text-warning">{% trans "Suspend" %}</span>{% endif %}
</td>
<td>{{ vm.vcpu }}</td>
<td>{{ vm.memory|filesizeformat }}</td>
Expand Down
16 changes: 8 additions & 8 deletions interfaces/templates/interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,36 @@ <h2 class="page-header">{% trans "Interface" %}: {{ iface }}</h2>
<dl class="ml-3 row">
<dt class="col-4">{% trans "Interface" %}</dt>
<dd class="col-8"><strong>{{ iface }}</strong></dd>
<dt class="col-4">{% trans "IPv4" %} ({% ifequal ipv4 None %}{% trans 'None' %}{% else %}{{ ipv4_type }}{% endifequal %})</dt>
<dt class="col-4">{% trans "IPv4" %} ({% if ipv4 == None %}{% trans 'None' %}{% else %}{{ ipv4_type }}{% endif %})</dt>
<dd class="col-8">{{ ipv4 }}</dd>
<dt class="col-4">{% trans "IPv6" %} ({% ifequal ipv6 None %}{% trans 'None' %}{% else %}{{ ipv6_type }}{% endifequal %})</dt>
<dt class="col-4">{% trans "IPv6" %} ({% if ipv6 == None %}{% trans 'None' %}{% else %}{{ ipv6_type }}{% endif %})</dt>
<dd class="col-8">{{ ipv6 }}</dd>
<dt class="col-4">{% trans "MAC" %}</dt>
<dd class="col-8">{{ mac }}</dd>
<dt class="col-4">{% trans "Interface Type" %}</dt>
<dd class="col-8">{{ itype }}</dd>
{% ifequal itype 'bridge' %}
{% if itype == 'bridge' %}
<dt class="col-4">{% trans "Bridge Device" %}</dt>
<dd class="col-8">{{ bridge }}</dd>
{% endifequal %}
{% endif %}
<dt class="col-4">{% trans "Boot Mode" %}</dt>
<dd class="col-8">{{ start_mode }}</dd>
<dt class="col-4">{% trans "State" %}</dt>
<dd class="col-8">
<form action="" method="post" role="form" aria-label="Interface start/stop/delete form">{% csrf_token %}
{% ifequal state 0 %}
{% if state == 0 %}
<input type="submit" class="btn btn-sm btn-primary" name="start" value="{% trans "Start" %}">
<input type="submit" class="btn btn-sm btn-danger" name="delete" value="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
{% else %}
<input type="submit" class="btn btn-sm btn-secondary" name="stop" value="{% trans "Stop" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
{% endifequal %}
{% endif %}
</form>
</dd>
</dl>

<div class="col-sm-12">
<h5>{% trans 'Slaves' %}</h5>
{% ifequal itype 'bridge' %}
{% if itype == 'bridge' %}
<table class="table table-bordered">
<thead>
<tr>
Expand All @@ -91,7 +91,7 @@ <h5>{% trans 'Slaves' %}</h5>
{% endfor %}
</tbody>
</table>
{% endifequal %}
{% endif %}
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions interfaces/templates/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ <h2 class="page-header">{{ compute.name }}</h2>
{% else %}
{% for iface in ifaces_all %}
<div class="col-12 col-sm-4">
<div class="mb-3 card {% ifequal iface.state 1 %}border-success{% else %}border-danger{% endifequal %} shadow-sm">
<div class="card-header {% ifequal iface.state 1 %}bg-success{% else %}bg-danger{% endifequal %}">
<div class="mb-3 card {% if iface.state == 1 %}border-success{% else %}border-danger{% endif %} shadow-sm">
<div class="card-header {% if iface.state == 1 %}bg-success{% else %}bg-danger{% endif %}">
<h6 class="my-0 card-title">
<a class="card-link text-light" href="{% url 'interface' compute.id iface.name %}">{{ iface.name }}</a>
</h6>
Expand Down
2 changes: 1 addition & 1 deletion interfaces/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.urls import reverse
from libvirt import libvirtError
from computes.models import Compute
from interfaces.forms import AddInterface
from vrtManager.interface import wvmInterface, wvmInterfaces
from libvirt import libvirtError
from admin.decorators import superuser_only


Expand Down
Loading

0 comments on commit 6a0d04d

Please sign in to comment.