1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix: a test alert button; damage shown and warned of on restore

Audit of the alerts and backup verification: an operator could learn
that the alert mail or webhook works only from a real failure. Settings
> Alerts gets "Send a test alert", sent at once to the channels saved,
each channel's result shown. A damaged backup's reasons were only in a
tooltip, so not on a touch screen: they show under the badge. A restore
of a backup that a verification found damaged, or of an incremental on
a damaged base (shown as Ready), said nothing: the restore pages warn.
This commit is contained in:
catborise 2026-11-19 17:14:03 +03:00
parent dcd7e32df7
commit 2c8493ba8c
15 changed files with 254 additions and 70 deletions

View file

@ -94,8 +94,12 @@
</div>
{% endfor %}
</div>
<div class="border-top mt-3 pt-3 text-end">
<div class="border-top mt-3 pt-3 d-flex flex-wrap justify-content-end gap-2">
{# Save first: Enter in a field saves #}
<button type="submit" class="btn btn-primary">{% blocktrans %}Save {{ group_title }}{% endblocktrans %}</button>
{% if title == "Alerts" %}{# to the addresses and webhook saved #}
<button type="submit" name="test_alert" value="1" class="btn btn-outline-secondary order-first" formnovalidate>{% trans "Send a test alert" %}</button>
{% endif %}
</div>
</form>
</section>

View file

@ -13,6 +13,7 @@ from django.shortcuts import render
from django.utils.translation import gettext as _
from django.utils.translation import gettext_noop
from logs.audit import audit
from operations import alerts
from operations.utils import BOUNDS
from vrtManager.util import OperationError
@ -110,6 +111,17 @@ def appsettings(request):
settings_by_key = {s.key: s for s in AppSettings.objects.exclude(key="BOOTSTRAP_THEME")}
if request.method == "POST":
if "test_alert" in request.POST: # with the settings saved
results = alerts.test()
if not results:
messages.error(request, _("Set an alert e-mail address or webhook and save it first"))
for channel, error in results.items():
name = _("E-mail") if channel == "mail" else _("Webhook")
if error is None:
messages.success(request, _("%(channel)s: the test alert was sent") % {"channel": name})
else:
messages.error(request, _("%(channel)s: the test alert failed: %(error)s") % {"channel": name, "error": error})
return HttpResponseRedirect(request.get_full_path()) # the results are at the top
if "BOOTSTRAP_THEME" in request.POST:
theme = request.POST.get("BOOTSTRAP_THEME", "")
if theme not in themes_list: