|
|
@ -14,7 +14,8 @@ from distribusisinfo import DistribusisInfo |
|
|
|
from app import db |
|
|
|
|
|
|
|
|
|
|
|
def IsZipUploaded(distribusiname): |
|
|
|
class UserHelper: |
|
|
|
def is_zip_uploaded(distribusiname): |
|
|
|
userfolder = os.path.join("stash", distribusiname) |
|
|
|
if os.path.exists(userfolder): |
|
|
|
zipfilename = "{}.zip".format(distribusiname) |
|
|
@ -24,8 +25,7 @@ def IsZipUploaded(distribusiname): |
|
|
|
print("distribusi folder has no zipfile") |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def IsDistribusiLive(distribusiname): |
|
|
|
def is_distribusi_live(distribusiname): |
|
|
|
userfolder = os.path.join("stash", distribusiname) |
|
|
|
if os.path.exists(userfolder): |
|
|
|
zipfilename = "{}.zip".format(distribusiname) |
|
|
@ -37,8 +37,7 @@ def IsDistribusiLive(distribusiname): |
|
|
|
print("distribusi folder is empty") |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def IsCssSelected(distribusiname): |
|
|
|
def is_css_selected(distribusiname): |
|
|
|
userfolder = os.path.join("themes/userthemes", distribusiname) |
|
|
|
if os.path.exists(userfolder): |
|
|
|
for file in os.listdir(userfolder): |
|
|
@ -47,8 +46,7 @@ def IsCssSelected(distribusiname): |
|
|
|
print("distribusi folder has no css file") |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def HasDistribusi(): |
|
|
|
def has_distribusi(): |
|
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
|
distribusi = Distribusis.query.filter_by(userid=user.id).first() |
|
|
|
if distribusi is None: |
|
|
@ -56,15 +54,13 @@ def HasDistribusi(): |
|
|
|
return False |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
def CurrentDistribusi(): |
|
|
|
def current_distribusi(): |
|
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
|
if user.currentdistribusi is None: |
|
|
|
return "None" |
|
|
|
return user.currentdistribusi |
|
|
|
|
|
|
|
|
|
|
|
def ResetUserState(): |
|
|
|
def reset_user_state(): |
|
|
|
"""reset user state upon visiting index, so that distribusi workflow can |
|
|
|
be done correctly""" |
|
|
|
if not current_user.is_authenticated: |
|
|
@ -77,12 +73,9 @@ def ResetUserState(): |
|
|
|
db.session.rollback() |
|
|
|
flash("An error occured !", "danger") |
|
|
|
|
|
|
|
|
|
|
|
def DistribusiLimitReached(): |
|
|
|
def distribusi_limit_reached(): |
|
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
|
distribusiamount = len( |
|
|
|
DistribusisInfo.getuserdistribusis(user.email) |
|
|
|
) |
|
|
|
distribusiamount = len(DistribusisInfo.getuserdistribusis(user.email)) |
|
|
|
if user.tutor and distribusiamount > 14: |
|
|
|
print("tutor already has 15 distribusis") |
|
|
|
return True |
|
|
@ -90,9 +83,3 @@ def DistribusiLimitReached(): |
|
|
|
print("user already has 5 distribusis") |
|
|
|
return True |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def IsThemeSelected |
|
|
|
# def IsCustomThemePresent |
|
|
|
# def IsDistribusiLive |
|
|
|