distribusi-verse/verse/uploadpage.py

57 lines
1.8 KiB
Python

from flask import render_template
from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm
# UserPengguna
from statuspengguna.helper import (
IsZipUploaded,
CurrentDistribusi,
HasDistribusi,
IsDistribusiLive,
IsCssSelected,
DistribusiLimitReached,
)
from upload import UploadNewDistribusi, UploadUpdatedFiles
from distribusisinfo import DistribusisInfo
from distribusiselector import SelectorVisible
def UploadPage(uploadfolder):
"render upload page section of distribusi workflow"
distribusiform = DistribusiForm()
themeform = ThemeForm()
publicthemeform = PublicThemeForm()
publicthemeform.publicthemes.choices = DistribusisInfo.publicthemes()
selectorform = SelectorForm()
selectorform.distribusis.choices = DistribusisInfo.userdistribusinames()
selectorvisible = SelectorVisible()
current_distribusi = CurrentDistribusi()
if current_distribusi == "new" or HasDistribusi() is False:
uploadform = UploadNewDistribusi(uploadfolder)
else:
uploadform = UploadUpdatedFiles(uploadfolder)
files_uploaded = IsZipUploaded(uploadform.sitename.data)
distribusi_live = IsDistribusiLive(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
limit_reached = DistribusiLimitReached()
template = render_template(
"distribusi.html",
uploadform=uploadform,
distribusiform=distribusiform,
themeform=themeform,
publicthemeform=publicthemeform,
selectorform=selectorform,
files_uploaded=files_uploaded,
distribusi_live=distribusi_live,
css_selected=css_selected,
selectorvisible=selectorvisible,
limit_reached=limit_reached,
)
return template