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 %} diff --git a/verse/templates/distribusi.html b/verse/templates/distribusi.html index 5aea030..33b1d4d 100644 --- a/verse/templates/distribusi.html +++ b/verse/templates/distribusi.html @@ -1,66 +1,20 @@ {% extends "base.html" %} {% block main %}
- -
-

Step 1: Upload

-

Upload your files here, the only accepted file type is a zip file

-
- {{ uploadform.csrf_token }} -
- {{ uploadform.sitename.label }} - {{ uploadform.sitename }} - {% for message in uploadform.sitename.errors %} -
{{ message }}
- {% endfor %} -
-
- {{ uploadform.zipfile.label }} - {{ uploadform.zipfile }} - {% for message in uploadform.zipfile.errors %} -
{{ message }}
- {% endfor %} -
-
- {{ uploadform.submit }} -
-
- {% if success %} -

Your file has been uploaded successfully - {% endif %} -

+ {% block upload %} + {% include "distribusiworkflow/upload.html" %} + {% endblock upload%} -
-

(Optional) Step 2: Theme

-

Select your Theme here. If you want your own custom css, skip and go to - step 3. Don't forget to press Save

-
- {{ themeform.csrf_token }} -
- {{ themeform.theme.label }} - {{ themeform.theme }} -
-
- {{ themeform.save }} -
-
-
- -
-

(Optional) Step 3: Edit

-

Go to CSS editor

-
+ {% block theme %} + {% include "distribusiworkflow/theme.html" %} + {% endblock theme%} + + {% block editcss %} + {% include "distribusiworkflow/editcss.html" %} + {% endblock editcss%} -
-

Step 4: Distribusi

-

run distribusi on your files, this will generate your website and make - your content public.

-
- {{ distribusiform.csrf_token }} -
- {{ distribusiform.submit }} -
-
-
+ {% block launch %} + {% include "distribusiworkflow/launch.html" %} + {% endblock launch%}
{% endblock main %} diff --git a/verse/templates/distribusiworkflow/editcss.html b/verse/templates/distribusiworkflow/editcss.html new file mode 100644 index 0000000..e3d4214 --- /dev/null +++ b/verse/templates/distribusiworkflow/editcss.html @@ -0,0 +1,4 @@ +
+

(Optional) Step 3: Edit

+

Go to CSS editor

+
diff --git a/verse/templates/distribusiworkflow/launch.html b/verse/templates/distribusiworkflow/launch.html new file mode 100644 index 0000000..a13eec5 --- /dev/null +++ b/verse/templates/distribusiworkflow/launch.html @@ -0,0 +1,11 @@ +
+

Step 4: Distribusi

+

run distribusi on your files, this will generate your website and make + your content public.

+
+ {{ distribusiform.csrf_token }} +
+ {{ distribusiform.submit }} +
+
+
diff --git a/verse/templates/distribusiworkflow/theme.html b/verse/templates/distribusiworkflow/theme.html new file mode 100644 index 0000000..99fa7d9 --- /dev/null +++ b/verse/templates/distribusiworkflow/theme.html @@ -0,0 +1,15 @@ +
+

(Optional) Step 2: Theme

+

Select your Theme here. If you want your own custom css, skip and go to + step 3. Don't forget to press Save

+
+ {{ themeform.csrf_token }} +
+ {{ themeform.theme.label }} + {{ themeform.theme }} +
+
+ {{ themeform.save }} +
+
+
diff --git a/verse/templates/distribusiworkflow/upload.html b/verse/templates/distribusiworkflow/upload.html new file mode 100644 index 0000000..132997f --- /dev/null +++ b/verse/templates/distribusiworkflow/upload.html @@ -0,0 +1,27 @@ +
+

Step 1: Upload

+

Upload your files here, the only accepted file type is a zip file

+
+ {{ uploadform.csrf_token }} +
+ {{ uploadform.sitename.label }} + {{ uploadform.sitename }} + {% for message in uploadform.sitename.errors %} +
{{ message }}
+ {% endfor %} +
+
+ {{ uploadform.zipfile.label }} + {{ uploadform.zipfile }} + {% for message in uploadform.zipfile.errors %} +
{{ message }}
+ {% endfor %} +
+
+ {{ uploadform.submit }} +
+
+ {% if files_uploaded %} +

Your files have been uploaded successfully

+ {% endif %} +