mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
add log & alert messages for appsettings changes
This commit is contained in:
parent
2d5c701789
commit
c9d9fdb9e8
2 changed files with 50 additions and 18 deletions
|
@ -11,6 +11,7 @@
|
||||||
<!-- /.row -->
|
<!-- /.row -->
|
||||||
|
|
||||||
{% include 'errors_block.html' %}
|
{% include 'errors_block.html' %}
|
||||||
|
{% include 'messages_block.html' %}
|
||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
@ -51,7 +52,7 @@
|
||||||
<option {% if bootstrap_theme.value == theme %}selected{% endif %} value="{{ theme }}">{{ theme }}</option>
|
<option {% if bootstrap_theme.value == theme %}selected{% endif %} value="{{ theme }}">{{ theme }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<span class="text-muted">{% trans "After change please full refresh page with Ctrl + F5 "%}</span>
|
<span class="text-muted">{% trans "After change please full refresh page with 'Ctrl + F5' "%}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
|
import sass
|
||||||
|
import os
|
||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.contrib import messages
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from appsettings.models import AppSettings
|
|
||||||
|
|
||||||
import sass
|
from appsettings.models import AppSettings
|
||||||
import os
|
from logs.views import addlogmsg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def appsettings(request):
|
def appsettings(request):
|
||||||
|
@ -30,28 +35,54 @@ def appsettings(request):
|
||||||
scss_var = f"@import '{sass_dir.value}/wvc-theme/{theme}/variables';"
|
scss_var = f"@import '{sass_dir.value}/wvc-theme/{theme}/variables';"
|
||||||
scss_bootswatch = f"@import '{sass_dir.value}/wvc-theme/{theme}/bootswatch';"
|
scss_bootswatch = f"@import '{sass_dir.value}/wvc-theme/{theme}/bootswatch';"
|
||||||
scss_boot = f"@import '{sass_dir.value}/bootstrap-overrides.scss';"
|
scss_boot = f"@import '{sass_dir.value}/bootstrap-overrides.scss';"
|
||||||
|
|
||||||
with open(sass_dir.value + "/wvc-main.scss", "w") as main:
|
try:
|
||||||
main.write(scss_var + "\n" + scss_boot + "\n" + scss_bootswatch)
|
with open(sass_dir.value + "/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)
|
||||||
|
|
||||||
|
bootstrap_theme.value = theme
|
||||||
|
bootstrap_theme.save()
|
||||||
|
|
||||||
|
msg = _(f"Theme changed. Now: {theme}")
|
||||||
|
messages.success(request, msg)
|
||||||
|
except Exception as err:
|
||||||
|
msg = err
|
||||||
|
error_messages.append(msg)
|
||||||
|
|
||||||
css_compressed = sass.compile(string=scss_var + "\n"+ scss_boot + "\n" + scss_bootswatch, output_style='compressed')
|
addlogmsg(request.user.username, "", msg)
|
||||||
with open("static/" + "css/wvc-main.min.css", "w") as css:
|
|
||||||
css.write(css_compressed)
|
|
||||||
|
|
||||||
bootstrap_theme.value = theme
|
|
||||||
bootstrap_theme.save()
|
|
||||||
return HttpResponseRedirect(request.get_full_path())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
|
|
||||||
if 'SASS_DIR' in request.POST:
|
if 'SASS_DIR' in request.POST:
|
||||||
sass_dir.value = request.POST.get("SASS_DIR", "")
|
try:
|
||||||
sass_dir.save()
|
sass_dir.value = request.POST.get("SASS_DIR", "")
|
||||||
|
sass_dir.save()
|
||||||
|
|
||||||
|
msg = _(f"SASS directory path is changed. Now: {sass_dir.value}")
|
||||||
|
messages.success(request, msg)
|
||||||
|
except Exception as err:
|
||||||
|
msg = err
|
||||||
|
error_messages.append(msg)
|
||||||
|
|
||||||
|
addlogmsg(request.user.username, "", msg)
|
||||||
return HttpResponseRedirect(request.get_full_path())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
|
|
||||||
if 'VIEW_INSTANCE_DETAIL_BOTTOM_BAR' in request.POST:
|
if 'VIEW_INSTANCE_DETAIL_BOTTOM_BAR' in request.POST:
|
||||||
show_inst_bottom_bar.value = request.POST.get("VIEW_INSTANCE_DETAIL_BOTTOM_BAR", "")
|
try:
|
||||||
show_inst_bottom_bar.save()
|
show_inst_bottom_bar.value = request.POST.get("VIEW_INSTANCE_DETAIL_BOTTOM_BAR", "")
|
||||||
return HttpResponseRedirect(request.get_full_path())
|
show_inst_bottom_bar.save()
|
||||||
|
|
||||||
|
msg = _(f"Show bottom bar setting is changed. Now: {show_inst_bottom_bar.value}")
|
||||||
|
messages.success(request, msg)
|
||||||
|
except Exception as err:
|
||||||
|
msg = err
|
||||||
|
error_messages.append(msg)
|
||||||
|
|
||||||
|
addlogmsg(request.user.username, "", msg)
|
||||||
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
|
|
||||||
return render(request, 'appsettings.html', locals())
|
return render(request, 'appsettings.html', locals())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue