diff --git a/verse/start.py b/verse/start.py index ca33cc2..1634d5f 100644 --- a/verse/start.py +++ b/verse/start.py @@ -44,6 +44,7 @@ from forms.distribusiform import DistribusiForm from forms.themeform import ThemeForm from forms.editorform import EditorForm +from statuspengguna.helper import AreFilesUploaded # Tada! from distribusi.cli import build_argparser from distribusi.distribusi import distribusify @@ -134,9 +135,8 @@ def distribusi(): uploadform = UploadForm() distribusiform = DistribusiForm() themeform = ThemeForm() + files_uploaded = AreFilesUploaded() user = User.query.filter_by(email=current_user.email).first() - if user.distribusiname is None: - print("nothing to deploy!") if distribusiform.validate_on_submit(): zipfilename = "{}.zip".format(user.distribusiname) userfolder = os.path.join("stash", user.distribusiname) @@ -163,6 +163,7 @@ def distribusi(): uploadform=uploadform, distribusiform=distribusiform, themeform=themeform, + files_uploaded=files_uploaded, ) return template @@ -170,10 +171,10 @@ def distribusi(): @APP.route("/upload", methods=["POST"]) @login_required def upload(): - success = False uploadform = UploadForm() distribusiform = DistribusiForm() themeform = ThemeForm() + files_uploaded = False if uploadform.validate_on_submit(): user = User.query.filter_by(email=current_user.email).first() user.distribusiname = uploadform.sitename.data @@ -189,13 +190,13 @@ def upload(): copyzipfile = os.path.join(APP.config["UPLOAD_FOLDER"], zipfilename) shutil.copy(copyzipfile, newuserfolder) os.remove(os.path.join(APP.config["UPLOAD_FOLDER"], zipfilename)) - success = True + files_uploaded = AreFilesUploaded() template = render_template( "distribusi.html", uploadform=uploadform, distribusiform=distribusiform, - success=success, themeform=themeform, + files_uploaded=files_uploaded, ) return template @@ -206,6 +207,7 @@ def theme(): uploadform = UploadForm() distribusiform = DistribusiForm() themeform = ThemeForm() + files_uploaded = AreFilesUploaded() if themeform.validate_on_submit(): user = User.query.filter_by(email=current_user.email).first() newuserfolder = os.path.join("stash", user.distribusiname) @@ -220,6 +222,7 @@ def theme(): uploadform=uploadform, distribusiform=distribusiform, themeform=themeform, + files_uploaded=files_uploaded, ) return template @@ -228,11 +231,8 @@ def theme(): @login_required def editor(): editorform = EditorForm() + files_uploaded = AreFilesUploaded() user = User.query.filter_by(email=current_user.email).first() - files_uploaded = True - if user.distribusiname is None: - files_uploaded = False - print("no folder to add css to!") if editorform.validate_on_submit(): userfolder = os.path.join("stash", user.distribusiname) cssfilename = "{}.css".format(editorform.cssname.data) diff --git a/verse/statuspengguna/helper.py b/verse/statuspengguna/helper.py new file mode 100644 index 0000000..2b6b874 --- /dev/null +++ b/verse/statuspengguna/helper.py @@ -0,0 +1,17 @@ +import os +from flask_login import current_user +from usermodel import User + +def AreFilesUploaded(): + user = User.query.filter_by(email=current_user.email).first() + if user.distribusiname is None: + print("distribusi name is empty") + return False; + userfolder = os.path.join("stash", user.distribusiname) + if os.path.exists(userfolder): + print("folder found, files are uploaded") + return True; + +#def IsThemeSelected +#def IsCustomThemePresent +#def IsDistribusiLive diff --git a/verse/templates/base.html b/verse/templates/base.html index e81f857..338d8ad 100644 --- a/verse/templates/base.html +++ b/verse/templates/base.html @@ -15,6 +15,8 @@
{% block main %} {% endblock main %} + {% block body %} + {% endblock body %}