소스 검색

Updated views.py for use script

1Mike21 1 년 전
부모
커밋
d9f42154b9
1개의 변경된 파일9개의 추가작업 그리고 6개의 파일을 삭제
  1. 9 6
      views.py

+ 9 - 6
views.py

@@ -4,15 +4,17 @@ from django.http import HttpResponseRedirect
 from design_template.utils import handle_uploaded_file
 from design_template.forms import ColorsForm, LogoForm 
 from core import settings
+import subprocess
 
 def upload(request): 
     if request.method == 'POST': 
         form = LogoForm(request.POST, request.FILES) 
-        if form.is_valid(): 
-            name_system = request.POST['namesystem'] 
-            settings.NAME_SYSTEM = name_system
-            handle_uploaded_file(request.FILES['logo'])
-            messages.success(request, "The logo has been uploaded successfully. Please run command collectstatic")
+        if form.is_valid():  
+            settings.NAME_SYSTEM =  request.POST.get('namesystem') 
+            handle_uploaded_file(request.FILES.get('logo'))
+            form.save()
+            subprocess.run(["/root/sharix-open-webapp-base/bin/collectstatic.sh"])
+            messages.success(request, "The logo has been uploaded successfully.")
             return HttpResponseRedirect("/admin") 
     else: 
         form = LogoForm() 
@@ -77,7 +79,8 @@ a{{
 '''
         with open("design_template/static/design_template/colors.css", 'r+', encoding='utf-8') as file:
           file.write(css)
-        messages.success(request, "The colors changed successfully. Please run command collectstatic")
+        subprocess.run(["/root/sharix-open-webapp-base/bin/collectstatic.sh"])
+        messages.success(request, "The colors changed successfully.")
     else:    
       form = ColorsForm()
     return render(request,"admin/change_colors.html", {'form':form})