1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-07-31 12:41:08 +00:00

Templates cleanup

This commit is contained in:
Real-Gecko 2020-10-15 20:18:45 +06:00
parent 4f959eaee8
commit 01043ba8a8
42 changed files with 307 additions and 796 deletions

View file

@ -2,15 +2,19 @@
{% load i18n %}
{% load staticfiles %}
{% block title %}{% trans "Secrets" %} - {{ compute.name }}{% endblock %}
{% block style %}
<link rel="stylesheet" href="{% static "css/sortable-theme-bootstrap.css" %}" />
{% endblock %}
{% block page_heading %}{{ compute }} - {% trans "Secrets" %}{% endblock page_heading %}
{% block page_heading_extra %}{% include 'create_secret_block.html' %}{% endblock page_heading_extra %}
{% block content %}
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
{% include 'create_secret_block.html' %}
<h2 class="page-header">{% trans "Secrets" %}</h2>
<h2 class="page-header"></h2>
<nav aria-label="breadcrumb">
<ol class="breadcrumb bg-light shadow-sm">
<li class="breadcrumb-item active">
@ -38,9 +42,6 @@
</nav>
</div>
</div>
<!-- /.row -->
{% include 'errors_block.html' %}
<div class="row">
{% if not secrets_all %}

View file

@ -1,17 +1,12 @@
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from libvirt import libvirtError
from libvirt import (VIR_SECRET_USAGE_TYPE_NONE,
VIR_SECRET_USAGE_TYPE_CEPH,
VIR_SECRET_USAGE_TYPE_TLS,
VIR_SECRET_USAGE_TYPE_VOLUME,
VIR_SECRET_USAGE_TYPE_ISCSI)
from secrets.forms import AddSecret
from admin.decorators import superuser_only
from computes.models import Compute
from secrets.forms import AddSecret
from django.contrib import messages
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from libvirt import (VIR_SECRET_USAGE_TYPE_CEPH, VIR_SECRET_USAGE_TYPE_ISCSI, VIR_SECRET_USAGE_TYPE_NONE,
VIR_SECRET_USAGE_TYPE_TLS, VIR_SECRET_USAGE_TYPE_VOLUME, libvirtError)
from vrtManager.secrets import wvmSecrets
@ -24,7 +19,6 @@ def secrets(request, compute_id):
"""
secrets_all = []
error_messages = []
compute = get_object_or_404(Compute, pk=compute_id)
secret_usage_types = {
VIR_SECRET_USAGE_TYPE_NONE: "none",
@ -59,11 +53,12 @@ def secrets(request, compute_id):
data['ephemeral'],
data['private'],
data['usage_type'],
data['data'])
data['data'],
)
return HttpResponseRedirect(request.get_full_path())
else:
for msg_err in form.errors.values():
error_messages.append(msg_err.as_text())
messages.error(request, msg_err.as_text())
if 'delete' in request.POST:
uuid = request.POST.get('uuid', '')
conn.delete_secret(uuid)
@ -74,9 +69,9 @@ def secrets(request, compute_id):
try:
conn.set_secret_value(uuid, value)
except Exception as err:
error_messages.append(err)
messages.error(request, err)
return HttpResponseRedirect(request.get_full_path())
except libvirtError as err:
error_messages.append(err)
messages.error(request, err)
return render(request, 'secrets.html', locals())