Browse Source

a little code clean up

current_wdka_release
crunk 3 years ago
parent
commit
5922bfcef0
  1. 1
      verse/admintool.py
  2. 8
      verse/distribusiworkflow.py
  3. 4
      verse/editor.py
  4. 1
      verse/usermodel.py

1
verse/admintool.py

@ -9,6 +9,7 @@ from sqlalchemy.exc import (
from usermodel import User # noqa: F401
from distribusimodel import Distribusis # noqa: F401
def admintool():
"""Admin CLI tool. To elevate a user to admin"""
app = create_app()

8
verse/distribusiworkflow.py

@ -5,9 +5,9 @@ from flask import (
render_template,
redirect,
url_for,
flash,
)
from sqlalchemy.exc import (
IntegrityError,
InvalidRequestError,
DataError,
InterfaceError,
@ -77,9 +77,7 @@ def UnzipDistribusiFiles(distribusi, userfolder):
def GetCssFile(distribusi):
cssfile = ""
cssfolder = os.path.join(
"themes/userthemes", distribusi.distribusiname
)
cssfolder = os.path.join("themes/userthemes", distribusi.distribusiname)
for filename in os.listdir(cssfolder):
if filename.endswith(".css"):
cssfile = os.path.join(cssfolder, filename)
@ -99,7 +97,7 @@ def SetDistribusiToVisible(distribusi, user):
db.session.commit()
except (InvalidRequestError, DataError, InterfaceError, DatabaseError):
db.session.rollback()
distribusiform.submit.errors.append("Unknown error occured!")
flash("Unknown error occured!")
def DeleteCssFile(cssfile):

4
verse/editor.py

@ -63,10 +63,10 @@ def SaveUploadCssFile(editorform, newcssfolder):
cssfile = editorform.cssfile.data
cssfilename = f"{secure_filename(editorform.cssname.data)}.css"
cssfile.save(os.path.join(newcssfolder, cssfilename))
openfile = open(os.path.join(newcssfolder, cssfilename), 'r')
openfile = open(os.path.join(newcssfolder, cssfilename), "r")
cleancss = bleach.clean(openfile.read())
openfile.close()
cleanfile = open(os.path.join(newcssfolder, cssfilename), 'w')
cleanfile = open(os.path.join(newcssfolder, cssfilename), "w")
cleanfile.write(cleancss)
cleanfile.close()

1
verse/usermodel.py

@ -15,6 +15,5 @@ class User(UserMixin, db.Model):
tutor = db.Column(db.Boolean, default=False)
admin = db.Column(db.Boolean, default=False)
def __repr__(self):
return "<User %r>" % self.email

Loading…
Cancel
Save