|
@ -36,8 +36,15 @@ from forms.themeform import ThemeForm |
|
|
from forms.editorform import EditorForm |
|
|
from forms.editorform import EditorForm |
|
|
from forms.selectorform import SelectorForm |
|
|
from forms.selectorform import SelectorForm |
|
|
|
|
|
|
|
|
|
|
|
# CRUD! |
|
|
|
|
|
from selector import SelectNewDistribusi |
|
|
|
|
|
from selector import SelectUpdateDistribusi |
|
|
|
|
|
from selector import DeleteDistribusi |
|
|
|
|
|
from selector import SelectorVisible |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from statuspengguna.helper import AreFilesUploaded |
|
|
from statuspengguna.helper import AreFilesUploaded |
|
|
from statuspengguna.helper import HasDistribusi |
|
|
from statuspengguna.helper import CurrentDistribusi |
|
|
from statuspengguna.loginuser import LoginUser |
|
|
from statuspengguna.loginuser import LoginUser |
|
|
from statuspengguna.registeruser import RegisterUser |
|
|
from statuspengguna.registeruser import RegisterUser |
|
|
|
|
|
|
|
@ -76,10 +83,14 @@ def distribusi(): |
|
|
selectorform.distribusis.choices = distribusisfields() |
|
|
selectorform.distribusis.choices = distribusisfields() |
|
|
|
|
|
|
|
|
files_uploaded = AreFilesUploaded() |
|
|
files_uploaded = AreFilesUploaded() |
|
|
has_distribusi = HasDistribusi() |
|
|
selectorvisible = SelectorVisible() |
|
|
|
|
|
current_distribusi = CurrentDistribusi() |
|
|
|
|
|
|
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
distribusi = Distribusis.query.filter_by(userid=user.id).first() |
|
|
distribusi = Distribusis.query.filter_by( |
|
|
|
|
|
distribusiname=current_distribusi |
|
|
|
|
|
).first() |
|
|
|
|
|
|
|
|
if distribusiform.validate_on_submit(): |
|
|
if distribusiform.validate_on_submit(): |
|
|
zipfilename = "{}.zip".format(distribusi.distribusiname) |
|
|
zipfilename = "{}.zip".format(distribusi.distribusiname) |
|
|
userfolder = os.path.join("stash", distribusi.distribusiname) |
|
|
userfolder = os.path.join("stash", distribusi.distribusiname) |
|
@ -101,6 +112,7 @@ def distribusi(): |
|
|
args = parser.parse_args(["-s", cssfile]) |
|
|
args = parser.parse_args(["-s", cssfile]) |
|
|
distribusify(args, userfolder) |
|
|
distribusify(args, userfolder) |
|
|
distribusi.visible = True |
|
|
distribusi.visible = True |
|
|
|
|
|
user.currentdistribusi = None |
|
|
db.session.commit() |
|
|
db.session.commit() |
|
|
return redirect(url_for("index")) |
|
|
return redirect(url_for("index")) |
|
|
template = render_template( |
|
|
template = render_template( |
|
@ -110,7 +122,7 @@ def distribusi(): |
|
|
themeform=themeform, |
|
|
themeform=themeform, |
|
|
selectorform=selectorform, |
|
|
selectorform=selectorform, |
|
|
files_uploaded=files_uploaded, |
|
|
files_uploaded=files_uploaded, |
|
|
has_distribusi=has_distribusi, |
|
|
selectorvisible=selectorvisible, |
|
|
) |
|
|
) |
|
|
return template |
|
|
return template |
|
|
|
|
|
|
|
@ -125,7 +137,7 @@ def upload(): |
|
|
selectorform.distribusis.choices = distribusisfields() |
|
|
selectorform.distribusis.choices = distribusisfields() |
|
|
|
|
|
|
|
|
files_uploaded = AreFilesUploaded() |
|
|
files_uploaded = AreFilesUploaded() |
|
|
has_distribusi = HasDistribusi() |
|
|
selectorvisible = SelectorVisible() |
|
|
|
|
|
|
|
|
if uploadform.validate_on_submit(): |
|
|
if uploadform.validate_on_submit(): |
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
@ -139,6 +151,7 @@ def upload(): |
|
|
year=uploadform.academicyear.data, |
|
|
year=uploadform.academicyear.data, |
|
|
tags=uploadform.tags.data, |
|
|
tags=uploadform.tags.data, |
|
|
) |
|
|
) |
|
|
|
|
|
user.currentdistribusi = uploadform.sitename.data |
|
|
db.session.add(newdistribusi) |
|
|
db.session.add(newdistribusi) |
|
|
db.session.commit() |
|
|
db.session.commit() |
|
|
except InvalidRequestError: |
|
|
except InvalidRequestError: |
|
@ -171,7 +184,7 @@ def upload(): |
|
|
themeform=themeform, |
|
|
themeform=themeform, |
|
|
selectorform=selectorform, |
|
|
selectorform=selectorform, |
|
|
files_uploaded=files_uploaded, |
|
|
files_uploaded=files_uploaded, |
|
|
has_distribusi=has_distribusi, |
|
|
selectorvisible=selectorvisible, |
|
|
) |
|
|
) |
|
|
return template |
|
|
return template |
|
|
|
|
|
|
|
@ -186,12 +199,11 @@ def theme(): |
|
|
selectorform.distribusis.choices = distribusisfields() |
|
|
selectorform.distribusis.choices = distribusisfields() |
|
|
|
|
|
|
|
|
files_uploaded = AreFilesUploaded() |
|
|
files_uploaded = AreFilesUploaded() |
|
|
has_distribusi = HasDistribusi() |
|
|
selectorvisible = SelectorVisible() |
|
|
|
|
|
current_distribusi = CurrentDistribusi() |
|
|
|
|
|
|
|
|
if themeform.validate_on_submit(): |
|
|
if themeform.validate_on_submit(): |
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
newuserfolder = os.path.join("stash", current_distribusi) |
|
|
distribusi = Distribusis.query.filter_by(userid=user.id).first() |
|
|
|
|
|
newuserfolder = os.path.join("stash", distribusi.distribusiname) |
|
|
|
|
|
copycssfile = os.path.join( |
|
|
copycssfile = os.path.join( |
|
|
"themes", |
|
|
"themes", |
|
|
"{}.css".format(themeform.theme.data), |
|
|
"{}.css".format(themeform.theme.data), |
|
@ -205,7 +217,7 @@ def theme(): |
|
|
themeform=themeform, |
|
|
themeform=themeform, |
|
|
selectorform=selectorform, |
|
|
selectorform=selectorform, |
|
|
files_uploaded=files_uploaded, |
|
|
files_uploaded=files_uploaded, |
|
|
has_distribusi=has_distribusi, |
|
|
selectorvisible=selectorvisible, |
|
|
) |
|
|
) |
|
|
return template |
|
|
return template |
|
|
|
|
|
|
|
@ -215,9 +227,10 @@ def theme(): |
|
|
def editor(): |
|
|
def editor(): |
|
|
editorform = EditorForm() |
|
|
editorform = EditorForm() |
|
|
files_uploaded = AreFilesUploaded() |
|
|
files_uploaded = AreFilesUploaded() |
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
current_distribusi = CurrentDistribusi() |
|
|
|
|
|
|
|
|
if editorform.validate_on_submit(): |
|
|
if editorform.validate_on_submit(): |
|
|
userfolder = os.path.join("stash", user.distribusiname) |
|
|
userfolder = os.path.join("stash", current_distribusi) |
|
|
cssfilename = "{}.css".format(editorform.cssname.data) |
|
|
cssfilename = "{}.css".format(editorform.cssname.data) |
|
|
with open(os.path.join(userfolder, cssfilename), "w") as cssfile: |
|
|
with open(os.path.join(userfolder, cssfilename), "w") as cssfile: |
|
|
cssfile.write(editorform.css.data) |
|
|
cssfile.write(editorform.css.data) |
|
@ -234,12 +247,23 @@ def editor(): |
|
|
@APP.route("/selector", methods=["GET", "POST"]) |
|
|
@APP.route("/selector", methods=["GET", "POST"]) |
|
|
@login_required |
|
|
@login_required |
|
|
def selector(): |
|
|
def selector(): |
|
|
|
|
|
selectorform = SelectorForm() |
|
|
|
|
|
uploadform = UploadForm() |
|
|
|
|
|
distribusiform = DistribusiForm() |
|
|
|
|
|
themeform = ThemeForm() |
|
|
selectorform = SelectorForm() |
|
|
selectorform = SelectorForm() |
|
|
selectorform.distribusis.choices = distribusisfields() |
|
|
selectorform.distribusis.choices = distribusisfields() |
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
|
|
|
|
|
|
files_uploaded = AreFilesUploaded() |
|
|
|
|
|
selectorvisible = SelectorVisible() |
|
|
|
|
|
|
|
|
if selectorform.validate_on_submit(): |
|
|
if selectorform.validate_on_submit(): |
|
|
print(selectorform.distribusis.data) |
|
|
if selectorform.new.data: |
|
|
print() |
|
|
SelectNewDistribusi() |
|
|
|
|
|
if selectorform.delete.data: |
|
|
|
|
|
DeleteDistribusi(selectorform.distribusis.data) |
|
|
|
|
|
if selectorform.update.data: |
|
|
|
|
|
SelectUpdateDistribusi(selectorform.distribusis.data) |
|
|
template = render_template( |
|
|
template = render_template( |
|
|
"distribusi.html", |
|
|
"distribusi.html", |
|
|
uploadform=uploadform, |
|
|
uploadform=uploadform, |
|
@ -247,10 +271,11 @@ def selector(): |
|
|
themeform=themeform, |
|
|
themeform=themeform, |
|
|
selectorform=selectorform, |
|
|
selectorform=selectorform, |
|
|
files_uploaded=files_uploaded, |
|
|
files_uploaded=files_uploaded, |
|
|
has_distribusi=has_distribusi, |
|
|
selectorvisible=selectorvisible, |
|
|
) |
|
|
) |
|
|
return template |
|
|
return template |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@APP.route("/stash/<path:path>") |
|
|
@APP.route("/stash/<path:path>") |
|
|
def distribusistash(path): |
|
|
def distribusistash(path): |
|
|
return send_from_directory("stash", path) |
|
|
return send_from_directory("stash", path) |
|
|