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

bootstrap 4.5 & Bootswatch Themes

This commit is contained in:
catborise 2020-05-19 19:53:54 +03:00 committed by catborise
parent e2b7b77da0
commit 0e5840498e
230 changed files with 19531 additions and 5077 deletions

View file

@ -10,6 +10,8 @@ from accounts.models import *
from admin.decorators import superuser_only
from instances.models import Instance
import sass
import os
def profile(request):
"""
@ -21,6 +23,8 @@ def profile(request):
# user = User.objects.get(id=request.user.id)
publickeys = UserSSHKey.objects.filter(user_id=request.user.id)
themes_list = os.listdir(settings.SCSS_DIR +"/wvc-theme")
if request.method == 'POST':
if 'username' in request.POST:
username = request.POST.get('username', '')
@ -65,6 +69,20 @@ def profile(request):
delkeypublic = UserSSHKey.objects.get(id=keyid)
delkeypublic.delete()
return HttpResponseRedirect(request.get_full_path())
if 'change_theme' in request.POST:
theme = request.POST.get('theme_select', '')
scss_var = f"@import '{settings.SCSS_DIR}/wvc-theme/{theme}/variables';"
scss_bootswatch = f"@import '{settings.SCSS_DIR}/wvc-theme/{theme}/bootswatch';"
scss_boot = f"@import '{settings.SCSS_DIR}/bootstrap-overrides.scss';"
with open(settings.SCSS_DIR + "/wvc-main.scss", "w") as main:
main.write(scss_var + "\n" + scss_boot + "\n" + scss_bootswatch)
css_compressed = sass.compile(string=scss_var + "\n"+ scss_boot + "\n" + scss_bootswatch, output_style='compressed')
with open("static/" + "css/wvc-main.min.css", "w") as css:
css.write(css_compressed)
return HttpResponseRedirect(request.get_full_path())
return render(request, 'profile.html', locals())