1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00
webvirtcloud/computes/templates/computes/form.html
catborise 65b8110464 fix(tags): fourth audit: stale tag forms, rename after delete, stale filter
- A tags form carries the names it showed (show_hidden_initial): sent back
  unchanged, the VM's or host's tags are left as they are, so a form shown
  before a tag was renamed or deleted does not bring the old name back.
- A rename whose tag is deleted while it waits answers 404, not 500.
- A removed VM kept only for a deleted tag leaves the Removed VMs page.
- A kept tag filter the list no longer offers is forgotten, so a name made
  again later is not chosen by itself.
2026-11-19 07:53:14 +03:00

60 lines
3.4 KiB
HTML

{% extends "base.html" %}
{% load django_bootstrap5 %}
{% load i18n %}
{% load static %}
{% block title %}{% if form.instance.pk %}{% trans "Edit host" %}{% else %}{% trans "Add host" %}{% endif %}{% endblock %}
{% block page_heading %}
<span class="text-break">{% if form.instance.pk %}{% blocktrans with name=form.instance.name %}Edit host: {{ name }}{% endblocktrans %}{% else %}{% trans "Add host" %}{% endif %}</span>
<span class="badge text-bg-light border align-middle fs-6">{{ form.kind }}</span>
{% endblock page_heading %}
{% block style %}<link href="{% static 'css/tom-select.bootstrap5.min.css' %}" rel="stylesheet">{% endblock %}
{% block content %}
<p class="text-body-secondary">{{ form.about }}</p>
<form method="post">
{% csrf_token %}
{% bootstrap_form_errors form type='non_fields' %}
{% for field in form.hidden_fields %}{{ field }}{% endfor %}
<section class="card mb-3" aria-labelledby="connection-title">
<div class="card-header"><h2 class="h5 mb-0" id="connection-title">{% trans "Connection" %}</h2></div>
<div class="card-body">
<div class="row">
<div class="col-md-6">{% bootstrap_field form.name %}</div>
{% if not form.hostname.is_hidden %}<div class="col-md-6">{% bootstrap_field form.hostname %}</div>{% endif %}
{% if "login" in form.fields %}<div class="col-md-6">{% bootstrap_field form.login %}</div>{% endif %}
{% if "password" in form.fields %}<div class="col-md-6">{% bootstrap_field form.password %}</div>{% endif %}
<div class="col-12">{% bootstrap_field form.details %}</div>
<div class="col-12">{% bootstrap_field form.tags %}
{# the tags shown, sent back to tell them from a change (TagsField); bootstrap_field leaves them out #}
{% for name in form.tags.initial %}<input type="hidden" name="{{ form.tags.html_initial_name }}" value="{{ name }}">{% endfor %}
</div>
</div>
{# open when one of them is set or refused #}
<details class="border-top pt-3"{% if form.migration_address.value or form.migration_address.errors or form.gstfsd_key.errors %} open{% endif %}>
<summary>
<span class="fw-semibold">{% trans "Advanced" %}</span>
<span class="d-block small text-body-secondary text-break ms-3">
{% trans "Migration address" %}: {{ form.migration_address.value|default:_("the host name") }}
&middot; {% trans "gstfsd key" %}: {% if form.instance.gstfsd_key %}{% trans "stored" %}{% else %}{% trans "none" %}{% endif %}
</span>
</summary>
<div class="mt-3">
{% bootstrap_field form.migration_address %}
{% bootstrap_field form.gstfsd_key %}
</div>
</details>
</div>
</section>
<div class="d-flex justify-content-end gap-2">
<a class="btn btn-outline-secondary" href="{% url 'computes' %}">{% trans "Cancel" %}</a>
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
</div>
</form>
{% endblock content %}
{% block script %}
<script src="{% static 'js/tom-select.complete.min.js' %}"></script>
<script src="{% static 'js/searchable_select.js' %}"></script>
{% endblock script %}