forked from crunk/distribusi-verse
refactoring distribusi work flow page, upload section
This commit is contained in:
parent
123e78d3c4
commit
80f08d4bf9
@ -31,7 +31,7 @@ from statuspengguna.helper import (
|
||||
from app import db
|
||||
|
||||
|
||||
def SelectorPage():
|
||||
def DistribusiSelector():
|
||||
uploadform = UploadForm()
|
||||
selectorform = SelectorForm()
|
||||
selectorform.distribusis.choices = DistribusisInfo.userdistribusinames()
|
||||
|
@ -1,6 +1,5 @@
|
||||
"""This is the main flask distribusi page"""
|
||||
from datetime import timedelta
|
||||
|
||||
from flask import (
|
||||
render_template,
|
||||
redirect,
|
||||
@ -13,37 +12,23 @@ from flask_login import (
|
||||
login_required,
|
||||
current_user,
|
||||
)
|
||||
|
||||
from flask_wtf.csrf import CSRFError
|
||||
|
||||
from app import create_app, login_manager
|
||||
from usermodel import User
|
||||
|
||||
# Forms!
|
||||
# Use upload form to populate filters
|
||||
from forms.uploadform import UploadForm
|
||||
from forms.distribusiform import DistribusiForm
|
||||
from forms.themeform import ThemeForm
|
||||
from forms.publicthemeform import PublicThemeForm
|
||||
from forms.selectorform import SelectorForm
|
||||
|
||||
# Interface!
|
||||
# Interface! these are seperate files in main folder
|
||||
from adminpage import AdminPage
|
||||
from editor import Editor
|
||||
from themeselector import ThemeSelector
|
||||
from distribusiworkflow import DistribusiWorkflow
|
||||
from distribusiselector import SelectorPage, SelectorVisible
|
||||
from upload import UploadNewDistribusi, UploadUpdatedFiles
|
||||
from distribusiselector import DistribusiSelector
|
||||
from uploadpage import UploadPage
|
||||
|
||||
# UserPengguna
|
||||
from statuspengguna.helper import (
|
||||
IsZipUploaded,
|
||||
IsCssSelected,
|
||||
CurrentDistribusi,
|
||||
HasDistribusi,
|
||||
IsDistribusiLive,
|
||||
ResetUserState,
|
||||
DistribusiLimitReached,
|
||||
)
|
||||
from statuspengguna.helper import ResetUserState
|
||||
from statuspengguna.loginuser import LoginUser
|
||||
from statuspengguna.registeruser import RegisterUser
|
||||
from distribusisinfo import DistribusisInfo
|
||||
@ -98,36 +83,8 @@ def distribusi():
|
||||
@APP.route("/upload", methods=["POST"])
|
||||
@login_required
|
||||
def upload():
|
||||
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(APP.config["UPLOAD_FOLDER"])
|
||||
else:
|
||||
uploadform = UploadUpdatedFiles(APP.config["UPLOAD_FOLDER"])
|
||||
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
|
||||
uploadfolder = APP.config["UPLOAD_FOLDER"]
|
||||
return UploadPage(uploadfolder)
|
||||
|
||||
|
||||
@APP.route("/theme", methods=["GET", "POST"])
|
||||
@ -145,7 +102,7 @@ def editor():
|
||||
@APP.route("/selector", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def selector():
|
||||
return SelectorPage()
|
||||
return DistribusiSelector()
|
||||
|
||||
|
||||
@APP.route("/stash/<path:path>")
|
||||
|
@ -120,7 +120,8 @@ input[type="submit"]:disabled:focus {
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #aa5050;
|
||||
font-size: 110%;
|
||||
color: #F92020;
|
||||
}
|
||||
|
||||
#delete {
|
||||
|
@ -35,16 +35,18 @@ def UploadNewDistribusi(uploadfolder):
|
||||
user.currentdistribusi = uploadform.sitename.data
|
||||
db.session.add(newdistribusi)
|
||||
db.session.commit()
|
||||
except (InvalidRequestError, DataError, InterfaceError, DatabaseError):
|
||||
db.session.rollback()
|
||||
uploadform.sitename.errors.append("Something went wrong!")
|
||||
flash("Something went wrong!", "danger")
|
||||
except IntegrityError:
|
||||
db.session.rollback()
|
||||
uploadform.sitename.errors.append(
|
||||
"distribusi name already exists!"
|
||||
)
|
||||
flash("distribusi name already exists!", "warning")
|
||||
return uploadform
|
||||
except (InvalidRequestError, DataError, InterfaceError, DatabaseError):
|
||||
db.session.rollback()
|
||||
uploadform.sitename.errors.append("Something went wrong!")
|
||||
flash("Something went wrong!", "danger")
|
||||
return uploadform
|
||||
SelectCurrentDistribusi(newdistribusi.distribusiname)
|
||||
zipfilename = "{}.zip".format(newdistribusi.distribusiname)
|
||||
zipfile = uploadform.zipfile.data
|
||||
|
56
verse/uploadpage.py
Normal file
56
verse/uploadpage.py
Normal file
@ -0,0 +1,56 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user