distribusi-verse: medium-tech web app content management system for the web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.1 KiB

import os
import shutil
from flask import render_template
from statuspengguna.helper import (
IsZipUploaded,
IsCssSelected,
CurrentDistribusi,
IsDistribusiLive,
)
from distribusisinfo import DistribusisInfo
from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm
from forms.selectorform import SelectorForm
def ThemeSelector():
themeform = ThemeForm()
themeform.publicthemes.choices = DistribusisInfo.publicthemes()
current_distribusi = CurrentDistribusi()
if themeform.validate_on_submit():
newcssfolder = os.path.join("themes/userthemes", current_distribusi)
if not os.path.exists(newcssfolder):
os.mkdir(newcssfolder)
if themeform.theme.data:
copycssfile = os.path.join(
"themes",
f"{themeform.theme.data}.css",
)
if themeform.publicthemes.data:
publictheme = themeform.publicthemes.data
copycssfile = os.path.join(
"themes/publicthemes",
f"{distribusiname}",
f"{themename}.css",
)
shutil.copy(copycssfile, newcssfolder)
return RenderDistribusiTemplate(current_distribusi)
def RenderDistribusiTemplate(current_distribusi):
uploadform = UploadForm()
distribusiform = DistribusiForm()
themeform = ThemeForm()
themeform.publicthemes.choices = DistribusisInfo.publicthemes()
selectorform = SelectorForm()
files_uploaded = IsZipUploaded(current_distribusi)
distribusi_live = IsDistribusiLive(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
selectorvisible = False
template = render_template(
"distribusi.html",
uploadform=uploadform,
distribusiform=distribusiform,
themeform=themeform,
selectorform=selectorform,
files_uploaded=files_uploaded,
distribusi_live=distribusi_live,
css_selected=css_selected,
selectorvisible=selectorvisible,
)
return template