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
parent 4b02c98411
commit 1eaf40a4a0
220 changed files with 19368 additions and 5276 deletions

View file

@ -1,3 +1,4 @@
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.urls import reverse
@ -9,6 +10,8 @@ from instances.models import Instance
from accounts.models import *
from accounts.forms import UserAddForm
import sass
import os
@login_required
def profile(request):
@ -22,6 +25,8 @@ def profile(request):
publickeys = UserSSHKey.objects.filter(user_id=request.user.id)
show_profile_edit_password = settings.SHOW_PROFILE_EDIT_PASSWORD
themes_list = os.listdir(settings.SCSS_DIR +"/wvc-theme")
if request.method == 'POST':
if 'username' in request.POST:
username = request.POST.get('username', '')
@ -66,6 +71,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())