mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
lint with black python. convert f style strings to old one. some small fixes
This commit is contained in:
parent
c20c353a40
commit
508e3609be
54 changed files with 2123 additions and 1824 deletions
|
@ -1,29 +1,30 @@
|
|||
from django import template
|
||||
import re
|
||||
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def app_active(request, app_name):
|
||||
if request.resolver_match.app_name == app_name:
|
||||
return 'active'
|
||||
return ''
|
||||
return "active"
|
||||
return ""
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def view_active(request, view_name):
|
||||
if request.resolver_match.view_name == view_name:
|
||||
return 'active'
|
||||
return ''
|
||||
return "active"
|
||||
return ""
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def class_active(request, pattern):
|
||||
if re.search(pattern, request.path):
|
||||
# Not sure why 'class="active"' returns class=""active""
|
||||
return 'active'
|
||||
return ''
|
||||
return "active"
|
||||
return ""
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
|
|
|
@ -15,7 +15,7 @@ class ExceptionMiddleware:
|
|||
if isinstance(exception, libvirtError):
|
||||
messages.error(
|
||||
request,
|
||||
_('libvirt Error - %(exception)s') % {'exception': exception},
|
||||
_("libvirt Error - %(exception)s") % {"exception": exception},
|
||||
)
|
||||
return render(request, '500.html', status=500)
|
||||
return render(request, "500.html", status=500)
|
||||
# TODO: check connecting to host via VPN
|
||||
|
|
|
@ -20,9 +20,7 @@ MIDDLEWARE += [
|
|||
]
|
||||
|
||||
# DebugToolBar
|
||||
INTERNAL_IPS = (
|
||||
"127.0.0.1",
|
||||
)
|
||||
INTERNAL_IPS = ("127.0.0.1",)
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
"INTERCEPT_REDIRECTS": False,
|
||||
}
|
||||
|
|
|
@ -8,102 +8,102 @@ import os
|
|||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
SECRET_KEY = ''
|
||||
SECRET_KEY = ""
|
||||
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
# Application definition
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'bootstrap4',
|
||||
'django_icons',
|
||||
'django_otp',
|
||||
'django_otp.plugins.otp_totp',
|
||||
'accounts',
|
||||
'admin',
|
||||
'appsettings',
|
||||
'computes',
|
||||
'console',
|
||||
'datasource',
|
||||
'networks',
|
||||
'instances',
|
||||
'interfaces',
|
||||
'nwfilters',
|
||||
'storages',
|
||||
'secrets',
|
||||
'logs',
|
||||
'qr_code',
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"bootstrap4",
|
||||
"django_icons",
|
||||
"django_otp",
|
||||
"django_otp.plugins.otp_totp",
|
||||
"accounts",
|
||||
"admin",
|
||||
"appsettings",
|
||||
"computes",
|
||||
"console",
|
||||
"datasource",
|
||||
"networks",
|
||||
"instances",
|
||||
"interfaces",
|
||||
"nwfilters",
|
||||
"storages",
|
||||
"secrets",
|
||||
"logs",
|
||||
"qr_code",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django_otp.middleware.OTPMiddleware',
|
||||
'login_required.middleware.LoginRequiredMiddleware',
|
||||
'django.contrib.auth.middleware.RemoteUserMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'appsettings.middleware.AppSettingsMiddleware',
|
||||
'webvirtcloud.middleware.ExceptionMiddleware',
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.locale.LocaleMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django_otp.middleware.OTPMiddleware",
|
||||
"login_required.middleware.LoginRequiredMiddleware",
|
||||
"django.contrib.auth.middleware.RemoteUserMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"appsettings.middleware.AppSettingsMiddleware",
|
||||
"webvirtcloud.middleware.ExceptionMiddleware",
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'webvirtcloud.urls'
|
||||
ROOT_URLCONF = "webvirtcloud.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [
|
||||
os.path.join(BASE_DIR, 'templates'),
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [
|
||||
os.path.join(BASE_DIR, "templates"),
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'appsettings.context_processors.app_settings',
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
"appsettings.context_processors.app_settings",
|
||||
],
|
||||
'libraries': {
|
||||
'common_tags': 'webvirtcloud.common_tags',
|
||||
"libraries": {
|
||||
"common_tags": "webvirtcloud.common_tags",
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'webvirtcloud.wsgi.application'
|
||||
WSGI_APPLICATION = "webvirtcloud.wsgi.application"
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
||||
}
|
||||
}
|
||||
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
"django.contrib.auth.backends.ModelBackend",
|
||||
]
|
||||
|
||||
LOGIN_URL = '/accounts/login/'
|
||||
LOGIN_URL = "/accounts/login/"
|
||||
|
||||
LOGOUT_REDIRECT_URL = '/accounts/login/'
|
||||
LOGOUT_REDIRECT_URL = "/accounts/login/"
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
LANGUAGE_CODE = "en-us"
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
|
@ -111,30 +111,27 @@ USE_L10N = True
|
|||
|
||||
USE_TZ = True
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_URL = "/static/"
|
||||
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, "static"),
|
||||
]
|
||||
|
||||
LOCALE_PATHS = [
|
||||
'locale/',
|
||||
"locale/",
|
||||
]
|
||||
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"handlers": {
|
||||
"mail_admins": {
|
||||
"level": "ERROR",
|
||||
"class": "django.utils.log.AdminEmailHandler"
|
||||
}
|
||||
"mail_admins": {"level": "ERROR", "class": "django.utils.log.AdminEmailHandler"}
|
||||
},
|
||||
"loggers": {
|
||||
"django.request": {
|
||||
"handlers": ["mail_admins"],
|
||||
"level": "ERROR",
|
||||
"propagate": True
|
||||
"propagate": True,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -147,7 +144,7 @@ LOGGING = {
|
|||
WS_PORT = 6080
|
||||
|
||||
# Websock host
|
||||
WS_HOST = '0.0.0.0'
|
||||
WS_HOST = "0.0.0.0"
|
||||
|
||||
# Websock public port - 80 or 443 if reverse-proxy, else 6080
|
||||
WS_PUBLIC_PORT = 6080
|
||||
|
@ -156,22 +153,53 @@ WS_PUBLIC_PORT = 6080
|
|||
WS_PUBLIC_HOST = None
|
||||
|
||||
# Websock public path
|
||||
WS_PUBLIC_PATH = '/novncd/'
|
||||
WS_PUBLIC_PATH = "/novncd/"
|
||||
|
||||
# Websock Certificate for SSL
|
||||
WS_CERT = None
|
||||
|
||||
# List of console listen addresses
|
||||
QEMU_CONSOLE_LISTEN_ADDRESSES = (
|
||||
('127.0.0.1', 'Localhost'),
|
||||
('0.0.0.0', 'All interfaces'),
|
||||
("127.0.0.1", "Localhost"),
|
||||
("0.0.0.0", "All interfaces"),
|
||||
)
|
||||
|
||||
# List taken from http://qemu.weilnetz.de/qemu-doc.html#sec_005finvocation
|
||||
QEMU_KEYMAPS = ['ar', 'da', 'de', 'de-ch', 'en-gb', 'en-us', 'es', 'et', 'fi',
|
||||
'fo', 'fr', 'fr-be', 'fr-ca', 'fr-ch', 'hr', 'hu', 'is', 'it',
|
||||
'ja', 'lt', 'lv', 'mk', 'nl', 'nl-be', 'no', 'pl', 'pt',
|
||||
'pt-br', 'ru', 'sl', 'sv', 'th', 'tr']
|
||||
QEMU_KEYMAPS = [
|
||||
"ar",
|
||||
"da",
|
||||
"de",
|
||||
"de-ch",
|
||||
"en-gb",
|
||||
"en-us",
|
||||
"es",
|
||||
"et",
|
||||
"fi",
|
||||
"fo",
|
||||
"fr",
|
||||
"fr-be",
|
||||
"fr-ca",
|
||||
"fr-ch",
|
||||
"hr",
|
||||
"hu",
|
||||
"is",
|
||||
"it",
|
||||
"ja",
|
||||
"lt",
|
||||
"lv",
|
||||
"mk",
|
||||
"nl",
|
||||
"nl-be",
|
||||
"no",
|
||||
"pl",
|
||||
"pt",
|
||||
"pt-br",
|
||||
"ru",
|
||||
"sl",
|
||||
"sv",
|
||||
"th",
|
||||
"tr",
|
||||
]
|
||||
|
||||
# Keepalive interval and count for libvirt connections
|
||||
LIBVIRT_KEEPALIVE_INTERVAL = 5
|
||||
|
@ -183,5 +211,4 @@ SHOW_PROFILE_EDIT_PASSWORD = True
|
|||
|
||||
OTP_ENABLED = False
|
||||
|
||||
LOGIN_REQUIRED_IGNORE_VIEW_NAMES = ['accounts:email_otp']
|
||||
|
||||
LOGIN_REQUIRED_IGNORE_VIEW_NAMES = ["accounts:email_otp"]
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
from django.conf import settings
|
||||
from django.urls import include, path
|
||||
|
||||
from appsettings.views import appsettings
|
||||
from console.views import console
|
||||
from django.conf import settings
|
||||
from django.urls import include, path
|
||||
from instances.views import index
|
||||
|
||||
urlpatterns = [
|
||||
path('', index, name='index'),
|
||||
path('admin/', include(('admin.urls', 'admin'), namespace='admin')),
|
||||
path('accounts/', include('accounts.urls')),
|
||||
path('appsettings/', appsettings, name='appsettings'),
|
||||
path('computes/', include('computes.urls')),
|
||||
path('console/', console, name='console'),
|
||||
path('datasource/', include('datasource.urls')),
|
||||
path('instances/', include('instances.urls')),
|
||||
path('i18n/', include('django.conf.urls.i18n')),
|
||||
path('logs/', include('logs.urls')),
|
||||
path("", index, name="index"),
|
||||
path("admin/", include(("admin.urls", "admin"), namespace="admin")),
|
||||
path("accounts/", include("accounts.urls")),
|
||||
path("appsettings/", appsettings, name="appsettings"),
|
||||
path("computes/", include("computes.urls")),
|
||||
path("console/", console, name="console"),
|
||||
path("datasource/", include("datasource.urls")),
|
||||
path("instances/", include("instances.urls")),
|
||||
path("i18n/", include("django.conf.urls.i18n")),
|
||||
path("logs/", include("logs.urls")),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
|
@ -23,7 +22,7 @@ if settings.DEBUG:
|
|||
import debug_toolbar
|
||||
|
||||
urlpatterns += [
|
||||
path('__debug__/', include(debug_toolbar.urls)),
|
||||
path("__debug__/", include(debug_toolbar.urls)),
|
||||
]
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
@ -11,6 +11,6 @@ import os
|
|||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webvirtcloud.settings')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webvirtcloud.settings")
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
|
|
@ -16,7 +16,7 @@ exec(
|
|||
compile(
|
||||
open("/srv/webvirtcloud/venv/bin/activate", "rb").read(),
|
||||
"/srv/webvirtcloud/venv/bin/activate",
|
||||
"exec"
|
||||
"exec",
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue