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

@ -1,16 +1,14 @@
import sass
import os
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.decorators import login_required
import sass
from django.contrib import messages
from appsettings.models import AppSettings
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.utils.translation import gettext_lazy as _
from logs.views import addlogmsg
from appsettings.models import AppSettings
@login_required
@ -19,20 +17,18 @@ def appsettings(request):
:param request:
:return:
"""
error_messages = []
main_css = "wvc-main.min.css"
sass_dir = AppSettings.objects.get(key="SASS_DIR")
bootstrap_theme = AppSettings.objects.get(key="BOOTSTRAP_THEME")
try:
themes_list = os.listdir(sass_dir.value + "/wvc-theme")
except FileNotFoundError as err:
error_messages.append(err)
messages.error(request, err)
addlogmsg(request.user.username, "", err)
# Bootstrap settings related with filesystems, because of that they are excluded from other settings
appsettings = AppSettings.objects.exclude(description__startswith="Bootstrap").order_by("name")
if request.method == 'POST':
if 'SASS_DIR' in request.POST:
try:
@ -43,7 +39,7 @@ def appsettings(request):
messages.success(request, msg)
except Exception as err:
msg = err
error_messages.append(msg)
messages.error(request, msg)
addlogmsg(request.user.username, "", msg)
return HttpResponseRedirect(request.get_full_path())
@ -58,7 +54,8 @@ def appsettings(request):
with open(sass_dir.value + "/wvc-main.scss", "w") as main:
main.write(scss_var + "\n" + scss_boot + "\n" + scss_bootswatch + "\n")
css_compressed = sass.compile(string=scss_var + "\n"+ scss_boot + "\n" + scss_bootswatch, output_style='compressed')
css_compressed = sass.compile(string=scss_var + "\n" + scss_boot + "\n" + scss_bootswatch,
output_style='compressed')
with open("static/css/" + main_css, "w") as css:
css.write(css_compressed)
@ -69,7 +66,7 @@ def appsettings(request):
messages.success(request, msg)
except Exception as err:
msg = err
error_messages.append(msg)
messages.error(request, msg)
addlogmsg(request.user.username, "", msg)
return HttpResponseRedirect(request.get_full_path())
@ -84,7 +81,7 @@ def appsettings(request):
messages.success(request, msg)
except Exception as err:
msg = err
error_messages.append(msg)
messages.error(request, msg)
addlogmsg(request.user.username, "", msg)
return HttpResponseRedirect(request.get_full_path())