Browse Source

sort, format and move models to folder

main
crunk 7 months ago
parent
commit
9e48758767
  1. 17
      verse/adminpage.py
  2. 14
      verse/admintool.py
  3. 9
      verse/app.py
  4. 8
      verse/deploydb.py
  5. 24
      verse/distribusiselector.py
  6. 4
      verse/distribusisinfo.py
  7. 46
      verse/distribusiworkflow.py
  8. 32
      verse/editor.py
  9. 8
      verse/forms/admindistribusiform.py
  10. 8
      verse/forms/adminuserform.py
  11. 13
      verse/forms/editorform.py
  12. 8
      verse/forms/forgotpasswordform.py
  13. 9
      verse/forms/loginform.py
  14. 6
      verse/forms/publicthemeform.py
  15. 11
      verse/forms/registerform.py
  16. 8
      verse/forms/resetpasswordform.py
  17. 2
      verse/forms/selectorform.py
  18. 6
      verse/forms/themeform.py
  19. 59
      verse/forms/uploadform.py
  20. 23
      verse/migrations/env.py
  21. 23
      verse/models/distribusimodel.py
  22. 23
      verse/models/usermodel.py
  23. 48
      verse/start.py
  24. 15
      verse/statuspengguna/forgotpassword.py
  25. 17
      verse/statuspengguna/helper.py
  26. 16
      verse/statuspengguna/loginuser.py
  27. 25
      verse/statuspengguna/registeruser.py
  28. 26
      verse/statuspengguna/resetpassword.py
  29. 12
      verse/themeselector.py
  30. 19
      verse/upload.py
  31. 8
      verse/uploadpage.py

17
verse/adminpage.py

@ -1,21 +1,16 @@
import os import os
import shutil import shutil
from flask import render_template from flask import render_template
from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError,
InvalidRequestError)
from sqlalchemy.exc import (
DataError,
DatabaseError,
InterfaceError,
InvalidRequestError,
)
from app import db from app import db
from usermodel import User
from distribusimodel import Distribusis
from distribusisinfo import DistribusisInfo from distribusisinfo import DistribusisInfo
from forms.adminuserform import AdminUserForm
from forms.admindistribusiform import AdminDistribusiForm from forms.admindistribusiform import AdminDistribusiForm
from forms.adminuserform import AdminUserForm
from models.distribusimodel import Distribusis
from models.usermodel import User
def AdminPage(): def AdminPage():

14
verse/admintool.py

@ -1,13 +1,11 @@
import sys import sys
from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError,
InvalidRequestError)
from app import create_app, db from app import create_app, db
from sqlalchemy.exc import ( from models.distribusimodel import Distribusis # noqa: F401
InvalidRequestError, from models.usermodel import User # noqa: F401
InterfaceError,
DataError,
DatabaseError,
)
from usermodel import User # noqa: F401
from distribusimodel import Distribusis # noqa: F401
def admintool(): def admintool():

9
verse/app.py

@ -1,12 +1,11 @@
import os import os
from flask import Flask from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt from flask_bcrypt import Bcrypt
from flask_login import LoginManager
from flask_migrate import Migrate from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from flask_wtf.csrf import CSRFProtect from flask_wtf.csrf import CSRFProtect
from flask_login import (
LoginManager,
)
db = SQLAlchemy() db = SQLAlchemy()
migrate = Migrate() migrate = Migrate()
@ -26,7 +25,7 @@ def create_app():
APP.config["MAIL_PORT"] = 587 APP.config["MAIL_PORT"] = 587
APP.config["MAIL_USE_SSL"] = False APP.config["MAIL_USE_SSL"] = False
APP.config["MAIL_USE_TLS"] = True APP.config["MAIL_USE_TLS"] = True
APP.config['MAIL_USERNAME'] = "noreply@vvvvvvaria.org" APP.config["MAIL_USERNAME"] = "noreply@vvvvvvaria.org"
login_manager.session_protection = "strong" login_manager.session_protection = "strong"
login_manager.login_view = "index" login_manager.login_view = "index"

8
verse/deploydb.py

@ -1,11 +1,11 @@
def deploy(): def deploy():
"""Run deployment of database.""" """Run deployment of database."""
from app import create_app, db from flask_migrate import init, migrate, stamp, upgrade
from flask_migrate import upgrade, migrate, init, stamp
from app import create_app, db
from models.distribusimodel import Distribusis # noqa: F401
# This model is required for flask_migrate to make the table # This model is required for flask_migrate to make the table
from usermodel import User # noqa: F401 from models.usermodel import User # noqa: F401
from distribusimodel import Distribusis # noqa: F401
app = create_app() app = create_app()
app.app_context().push() app.app_context().push()

24
verse/distribusiselector.py

@ -1,29 +1,23 @@
import os import os
import shutil import shutil
from flask import flash, render_template from flask import flash, render_template
from flask_login import current_user from flask_login import current_user
from sqlalchemy.exc import ( from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError,
DataError, InvalidRequestError)
DatabaseError,
InterfaceError,
InvalidRequestError,
)
from usermodel import User from app import db
from distribusimodel import Distribusis
from distribusisinfo import DistribusisInfo from distribusisinfo import DistribusisInfo
from forms.selectorform import SelectorForm
from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm
from forms.themeform import ThemeForm
from forms.uploadform import UploadForm
from models.distribusimodel import Distribusis
from models.usermodel import User
# UserPengguna # UserPengguna
from statuspengguna.helper import UserHelper from statuspengguna.helper import UserHelper
from app import db
def DistribusiSelector(): def DistribusiSelector():
uploadform = UploadForm() uploadform = UploadForm()

4
verse/distribusisinfo.py

@ -1,7 +1,7 @@
from flask_login import current_user from flask_login import current_user
from usermodel import User from models.distribusimodel import Distribusis
from distribusimodel import Distribusis from models.usermodel import User
class DistribusisInfo: class DistribusisInfo:

46
verse/distribusiworkflow.py

@ -1,40 +1,28 @@
import os import os
import shutil import shutil
import zipfile import zipfile
from flask_login import current_user
from flask import (
render_template,
redirect,
url_for,
flash,
)
from sqlalchemy.exc import (
InvalidRequestError,
DataError,
InterfaceError,
DatabaseError,
)
from app import db
from usermodel import User # Tada!
from distribusimodel import Distribusis from distribusi.cli import build_argparser
from distribusi.distribusi import distribusify
from flask import flash, redirect, render_template, url_for
from flask_login import current_user
from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError,
InvalidRequestError)
# UserPengguna from app import db
from statuspengguna.helper import UserHelper
from distribusiselector import SelectorVisible from distribusiselector import SelectorVisible
from distribusisinfo import DistribusisInfo
# Forms!
from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm from forms.selectorform import SelectorForm
from forms.themeform import ThemeForm
from distribusisinfo import DistribusisInfo # Forms!
from forms.uploadform import UploadForm
# Tada! from models.distribusimodel import Distribusis
from distribusi.cli import build_argparser from models.usermodel import User
from distribusi.distribusi import distribusify # UserPengguna
from statuspengguna.helper import UserHelper
def DistribusiWorkflow(): def DistribusiWorkflow():
@ -78,7 +66,7 @@ def CleanUpDistribusiFiles(userfolder):
def RemoveMacFolders(path): def RemoveMacFolders(path):
for filename in os.listdir(path): for filename in os.listdir(path):
fullpath = os.path.join(path, filename) fullpath = os.path.join(path, filename)
if filename.startswith('.'): if filename.startswith("."):
if os.path.isdir(fullpath): if os.path.isdir(fullpath):
shutil.rmtree(fullpath) shutil.rmtree(fullpath)
else: else:

32
verse/editor.py

@ -1,28 +1,23 @@
import os import os
import shutil
import bleach import bleach
from bleach_allowlist import all_styles from bleach_allowlist import all_styles
import shutil
from flask import render_template from flask import render_template
from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError,
InvalidRequestError)
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from sqlalchemy.exc import (
DataError,
DatabaseError,
InterfaceError,
InvalidRequestError,
)
from app import db
from distribusimodel import Distribusis
from statuspengguna.helper import UserHelper from app import db
from distribusisinfo import DistribusisInfo from distribusisinfo import DistribusisInfo
from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm
from forms.editorform import EditorForm from forms.editorform import EditorForm
from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm from forms.selectorform import SelectorForm
from forms.themeform import ThemeForm
from forms.uploadform import UploadForm
from models.distribusimodel import Distribusis
from statuspengguna.helper import UserHelper
def Editor(): def Editor():
@ -68,7 +63,7 @@ def SaveUploadCssFile(editorform, newcssfolder):
cssfile.save(os.path.join(newcssfolder, cssfilename)) 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(), all_styles) cleancss = bleach.clean(openfile.read(), all_styles)
cleancss = cleancss.replace('>', '>') cleancss = cleancss.replace(">", ">")
openfile.close() openfile.close()
cleanfile = open(os.path.join(newcssfolder, cssfilename), "w") cleanfile = open(os.path.join(newcssfolder, cssfilename), "w")
cleanfile.write(cleancss) cleanfile.write(cleancss)
@ -81,7 +76,7 @@ def WriteCssToFile(editorform, newcssfolder):
cssfilename = f"{secure_filename(editorform.cssname.data)}.css" cssfilename = f"{secure_filename(editorform.cssname.data)}.css"
cleancss = bleach.clean(editorform.css.data, all_styles) cleancss = bleach.clean(editorform.css.data, all_styles)
cleancss = cleancss.replace('>', '>') cleancss = cleancss.replace(">", ">")
with open(os.path.join(newcssfolder, cssfilename), "w") as cssfile: with open(os.path.join(newcssfolder, cssfilename), "w") as cssfile:
cssfile.write(cleancss) cssfile.write(cleancss)
cssfile.close cssfile.close
@ -91,8 +86,7 @@ def CopyPublicToUserFolder(editorform, publicfolder, newcssfolder):
if not os.path.exists(newcssfolder): if not os.path.exists(newcssfolder):
os.mkdir(newcssfolder) os.mkdir(newcssfolder)
copycssfile = os.path.join( copycssfile = os.path.join(
publicfolder, publicfolder, f"{secure_filename(editorform.cssname.data)}.css"
f"{secure_filename(editorform.cssname.data)}.css"
) )
print(f"copying file: {copycssfile}") print(f"copying file: {copycssfile}")
print(f"to folder: {newcssfolder}") print(f"to folder: {newcssfolder}")

8
verse/forms/admindistribusiform.py

@ -1,9 +1,7 @@
"""Form object declaration.""" """Form object declaration."""
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import ( from wtforms import BooleanField, SubmitField
BooleanField,
SubmitField,
)
class AdminDistribusiForm(FlaskForm): class AdminDistribusiForm(FlaskForm):
@ -15,7 +13,7 @@ class AdminDistribusiForm(FlaskForm):
class DistribusiListForm(AdminDistribusiForm): class DistribusiListForm(AdminDistribusiForm):
pass pass
for (i, distribusi) in enumerate(distribusis): for i, distribusi in enumerate(distribusis):
setattr( setattr(
DistribusiListForm, DistribusiListForm,
f"distribusi_{i}", f"distribusi_{i}",

8
verse/forms/adminuserform.py

@ -1,9 +1,7 @@
"""Form object declaration.""" """Form object declaration."""
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import ( from wtforms import BooleanField, SubmitField
SubmitField,
BooleanField,
)
class AdminUserForm(FlaskForm): class AdminUserForm(FlaskForm):
@ -13,7 +11,7 @@ class AdminUserForm(FlaskForm):
class UserListForm(AdminUserForm): class UserListForm(AdminUserForm):
pass pass
for (i, user) in enumerate(users): for i, user in enumerate(users):
setattr( setattr(
UserListForm, UserListForm,
f"user_{i}", f"user_{i}",

13
verse/forms/editorform.py

@ -1,15 +1,10 @@
"""Form to save your CSS editor work.""" """Form to save your CSS editor work."""
from wtforms import (
StringField,
TextAreaField,
BooleanField,
SubmitField,
)
from wtforms import validators
from wtforms.validators import Length
from flask_wtf.file import FileField, FileAllowed, FileSize
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField, FileSize
from wtforms import (BooleanField, StringField, SubmitField, TextAreaField,
validators)
from wtforms.validators import Length
class EditorForm(FlaskForm): class EditorForm(FlaskForm):

8
verse/forms/forgotpasswordform.py

@ -1,12 +1,8 @@
"""Forgotten password form to help user.""" """Forgotten password form to help user."""
from wtforms import (
StringField,
SubmitField,
)
from wtforms import validators
from wtforms.validators import Length, Email
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, validators
from wtforms.validators import Email, Length
class ForgotPasswordForm(FlaskForm): class ForgotPasswordForm(FlaskForm):

9
verse/forms/loginform.py

@ -1,13 +1,8 @@
"""Login form to validate user.""" """Login form to validate user."""
from wtforms import (
StringField,
SubmitField,
PasswordField,
)
from wtforms import validators
from wtforms.validators import Length, Email
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import PasswordField, StringField, SubmitField, validators
from wtforms.validators import Email, Length
class LoginForm(FlaskForm): class LoginForm(FlaskForm):

6
verse/forms/publicthemeform.py

@ -1,9 +1,7 @@
"""Form object declaration.""" """Form object declaration."""
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import ( from wtforms import RadioField, SubmitField
RadioField,
SubmitField,
)
class PublicThemeForm(FlaskForm): class PublicThemeForm(FlaskForm):

11
verse/forms/registerform.py

@ -1,13 +1,8 @@
"""Register form to make a new user.""" """Register form to make a new user."""
from wtforms import (
StringField,
SubmitField,
PasswordField,
)
from wtforms import validators
from wtforms.validators import Length, Email, EqualTo, ValidationError
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import PasswordField, StringField, SubmitField, validators
from wtforms.validators import Email, EqualTo, Length, ValidationError
class RegisterForm(FlaskForm): class RegisterForm(FlaskForm):
@ -29,7 +24,7 @@ class RegisterForm(FlaskForm):
Email(), Email(),
Length(6, 64), Length(6, 64),
hremail, hremail,
] ],
) )
password = PasswordField( password = PasswordField(

8
verse/forms/resetpasswordform.py

@ -1,12 +1,8 @@
"""Reset Password Form form to reset a users PasswordField.""" """Reset Password Form form to reset a users PasswordField."""
from wtforms import (
SubmitField,
PasswordField,
)
from wtforms import validators
from wtforms.validators import Length, EqualTo
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import PasswordField, SubmitField, validators
from wtforms.validators import EqualTo, Length
class ResetPasswordForm(FlaskForm): class ResetPasswordForm(FlaskForm):

2
verse/forms/selectorform.py

@ -1,5 +1,5 @@
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import SubmitField, SelectField from wtforms import SelectField, SubmitField
class SelectorForm(FlaskForm): class SelectorForm(FlaskForm):

6
verse/forms/themeform.py

@ -1,9 +1,7 @@
"""Form object declaration.""" """Form object declaration."""
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import ( from wtforms import RadioField, SubmitField
RadioField,
SubmitField,
)
class ThemeForm(FlaskForm): class ThemeForm(FlaskForm):

59
verse/forms/uploadform.py

@ -1,18 +1,9 @@
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed, FileRequired, FileSize from flask_wtf.file import FileAllowed, FileField, FileRequired, FileSize
from wtforms import validators from wtforms import (IntegerField, SelectField, StringField, SubmitField,
from wtforms.validators import ( validators)
Length, from wtforms.validators import (DataRequired, Length, NumberRange,
NumberRange, ValidationError)
DataRequired,
ValidationError,
)
from wtforms import (
SubmitField,
StringField,
IntegerField,
SelectField,
)
class UploadForm(FlaskForm): class UploadForm(FlaskForm):
@ -24,40 +15,44 @@ class UploadForm(FlaskForm):
sitename = StringField( sitename = StringField(
"Name of your archive section:", "Name of your archive section:",
validators=[validators.InputRequired(), Length(2, 100), _distribusiname], validators=[
validators.InputRequired(),
Length(2, 100),
_distribusiname,
],
) )
year = SelectField( year = SelectField(
"Year:", "Year:",
validate_choice=True, validate_choice=True,
coerce=str, coerce=str,
choices=[ choices=[
(u'2017', u'2017'), ("2017", "2017"),
(u'2018', u'2018'), ("2018", "2018"),
(u'2019', u'2019'), ("2019", "2019"),
(u'2020', u'2020'), ("2020", "2020"),
(u'2021', u'2021'), ("2021", "2021"),
(u'2022', u'2022'), ("2022", "2022"),
(u'2023', u'2023'), ("2023", "2023"),
(u'2024', u'2024'), ("2024", "2024"),
(u'2025', u'2025'), ("2025", "2025"),
], ],
option_widget=None, option_widget=None,
validators=[DataRequired()] validators=[DataRequired()],
) )
category = SelectField( category = SelectField(
"Category:", "Category:",
validate_choice=True, validate_choice=True,
coerce=str, coerce=str,
choices=[ choices=[
(u'event', u'event'), ("event", "event"),
(u'gathering', u'gathering'), ("gathering", "gathering"),
(u'work session', u'work session'), ("work session", "work session"),
(u'workgroup', u'workgroup'), ("workgroup", "workgroup"),
(u'performance', u'performance'), ("performance", "performance"),
(u'music event', u'music event'), ("music event", "music event"),
], ],
option_widget=None, option_widget=None,
validators=[DataRequired()] validators=[DataRequired()],
) )
tags = StringField( tags = StringField(
"Add tags, seperated by commas. No need for the '#' sign:", "Add tags, seperated by commas. No need for the '#' sign:",

23
verse/migrations/env.py

@ -3,9 +3,8 @@ from __future__ import with_statement
import logging import logging
from logging.config import fileConfig from logging.config import fileConfig
from flask import current_app
from alembic import context from alembic import context
from flask import current_app
# this is the Alembic Config object, which provides # this is the Alembic Config object, which provides
# access to the values within the .ini file in use. # access to the values within the .ini file in use.
@ -14,17 +13,19 @@ config = context.config
# Interpret the config file for Python logging. # Interpret the config file for Python logging.
# This line sets up loggers basically. # This line sets up loggers basically.
fileConfig(config.config_file_name) fileConfig(config.config_file_name)
logger = logging.getLogger('alembic.env') logger = logging.getLogger("alembic.env")
# add your model's MetaData object here # add your model's MetaData object here
# for 'autogenerate' support # for 'autogenerate' support
# from myapp import mymodel # from myapp import mymodel
# target_metadata = mymodel.Base.metadata # target_metadata = mymodel.Base.metadata
config.set_main_option( config.set_main_option(
'sqlalchemy.url', "sqlalchemy.url",
str(current_app.extensions['migrate'].db.get_engine().url).replace( str(current_app.extensions["migrate"].db.get_engine().url).replace(
'%', '%%')) "%", "%%"
target_metadata = current_app.extensions['migrate'].db.metadata ),
)
target_metadata = current_app.extensions["migrate"].db.metadata
# other values from the config, defined by the needs of env.py, # other values from the config, defined by the needs of env.py,
# can be acquired: # can be acquired:
@ -65,20 +66,20 @@ def run_migrations_online():
# when there are no changes to the schema # when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives): def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False): if getattr(config.cmd_opts, "autogenerate", False):
script = directives[0] script = directives[0]
if script.upgrade_ops.is_empty(): if script.upgrade_ops.is_empty():
directives[:] = [] directives[:] = []
logger.info('No changes in schema detected.') logger.info("No changes in schema detected.")
connectable = current_app.extensions['migrate'].db.get_engine() connectable = current_app.extensions["migrate"].db.get_engine()
with connectable.connect() as connection: with connectable.connect() as connection:
context.configure( context.configure(
connection=connection, connection=connection,
target_metadata=target_metadata, target_metadata=target_metadata,
process_revision_directives=process_revision_directives, process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args **current_app.extensions["migrate"].configure_args,
) )
with context.begin_transaction(): with context.begin_transaction():

23
verse/models/distribusimodel.py

@ -0,0 +1,23 @@
from app import db
class Distribusis(db.Model):
"""distribusi model class for a single distribusi in distribusi-verse"""
__tablename__ = "distribusis"
id = db.Column(db.Integer, primary_key=True)
distribusiname = db.Column(db.String(300), nullable=False, unique=True)
userid = db.Column(db.Integer, db.ForeignKey("users.id"))
term = db.Column(db.String(5), nullable=False, unique=False)
category = db.Column(db.String(500), nullable=True, unique=False)
# Academic year eg:2020-2021, so no need for a Datetime object
year = db.Column(db.String(9), nullable=True, unique=False)
tags = db.Column(db.String(500), nullable=True, unique=False)
publictheme = db.Column(db.String(300), unique=True, nullable=True)
visible = db.Column(db.Boolean, default=False)
def __repr__(self):
return "<Distribusi %r>" % self.distribusiname

23
verse/models/usermodel.py

@ -0,0 +1,23 @@
from flask_login import UserMixin
from app import db
class User(UserMixin, db.Model):
"""User model class for a user in distribusi-verse"""
__tablename__ = "users"
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(150), unique=True, nullable=False)
email = db.Column(db.String(150), unique=True, nullable=False)
password = db.Column(db.String(300), nullable=False, unique=False)
currentdistribusi = db.Column(db.String(300), nullable=True, unique=False)
resethash = db.Column(db.String(300), nullable=True, unique=True)
resettime = db.Column(db.DateTime)
# active = db.Column(db.Boolean, default=False)
tutor = db.Column(db.Boolean, default=False)
admin = db.Column(db.Boolean, default=False)
def __repr__(self):
return "<User %r>" % self.email

48
verse/start.py

@ -1,45 +1,33 @@
"""This is the main flask distribusi page""" """This is the main flask distribusi page"""
from datetime import timedelta from datetime import timedelta
from flask import (
render_template, from flask import (Blueprint, redirect, render_template, send_from_directory,
redirect, session, url_for)
url_for, from flask_login import current_user, login_required, logout_user
session,
send_from_directory,
Blueprint,
)
from flask_login import (
logout_user,
login_required,
current_user,
)
from flask_mail import Mail from flask_mail import Mail
from flask_wtf.csrf import CSRFError from flask_wtf.csrf import CSRFError
from app import create_app, login_manager
from usermodel import User
from distribusimodel import Distribusis
# Use upload form to populate filters
from forms.uploadform import UploadForm
# Interface! these are seperate files in main folder # Interface! these are seperate files in main folder
from adminpage import AdminPage from adminpage import AdminPage
from editor import Editor from app import create_app, login_manager
from themeselector import ThemeSelector
from distribusiworkflow import DistribusiWorkflow
from distribusiselector import DistribusiSelector from distribusiselector import DistribusiSelector
from uploadpage import UploadPage # Distribusi Information
from distribusisinfo import DistribusisInfo
from distribusiworkflow import DistribusiWorkflow
from editor import Editor
# Use upload form to populate filters
from forms.uploadform import UploadForm
from models.distribusimodel import Distribusis
from models.usermodel import User
from statuspengguna.forgotpassword import ForgotPassword
# UserPengguna # UserPengguna
from statuspengguna.helper import UserHelper from statuspengguna.helper import UserHelper
from statuspengguna.loginuser import LoginUser from statuspengguna.loginuser import LoginUser
from statuspengguna.registeruser import RegisterUser from statuspengguna.registeruser import RegisterUser
from statuspengguna.forgotpassword import ForgotPassword
from statuspengguna.resetpassword import ResetPassword from statuspengguna.resetpassword import ResetPassword
from themeselector import ThemeSelector
# Distribusi Information from uploadpage import UploadPage
from distribusisinfo import DistribusisInfo
APP = create_app() APP = create_app()
stash_page = Blueprint("stash_page", __name__, static_folder="stash") stash_page = Blueprint("stash_page", __name__, static_folder="stash")
@ -56,7 +44,6 @@ def session_handler():
@APP.route("/") @APP.route("/")
def index(): def index():
UserHelper.reset_user_state() UserHelper.reset_user_state()
# http://localhost:5000/themes/publicthemes/RomeroTape/blueskies.css
uploadform = UploadForm() uploadform = UploadForm()
distribusis = DistribusisInfo.visibledistribusis() distribusis = DistribusisInfo.visibledistribusis()
distribusisindex = {} distribusisindex = {}
@ -66,7 +53,6 @@ def index():
"username": user.username, "username": user.username,
"publictheme": distribusi.publictheme, "publictheme": distribusi.publictheme,
"category": distribusi.term, "category": distribusi.term,
"course": distribusi.course,
"year": distribusi.year, "year": distribusi.year,
"tags": distribusi.tags.split(","), "tags": distribusi.tags.split(","),
} }

15
verse/statuspengguna/forgotpassword.py

@ -1,17 +1,14 @@
from uuid import uuid1
from datetime import datetime from datetime import datetime
from sqlalchemy.exc import ( from uuid import uuid1
DataError,
DatabaseError,
InterfaceError,
InvalidRequestError,
)
from flask import render_template from flask import render_template
from flask_mail import Message from flask_mail import Message
from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError,
InvalidRequestError)
from usermodel import User
from forms.forgotpasswordform import ForgotPasswordForm
from app import db from app import db
from forms.forgotpasswordform import ForgotPasswordForm
from models.usermodel import User
def ForgotPassword(mail): def ForgotPassword(mail):

17
verse/statuspengguna/helper.py

@ -1,17 +1,14 @@
import os import os
from flask_login import current_user
from flask import flash from flask import flash
from sqlalchemy.exc import ( from flask_login import current_user
DataError, from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError,
DatabaseError, InvalidRequestError)
InterfaceError,
InvalidRequestError,
)
from usermodel import User
from distribusimodel import Distribusis
from distribusisinfo import DistribusisInfo
from app import db from app import db
from distribusisinfo import DistribusisInfo
from models.distribusimodel import Distribusis
from models.usermodel import User
class UserHelper: class UserHelper:

16
verse/statuspengguna/loginuser.py

@ -1,15 +1,9 @@
from flask import ( from flask import abort, flash, redirect, render_template, request, url_for
render_template,
redirect,
request,
flash,
url_for,
abort,
)
from usermodel import User
from forms.loginform import LoginForm
from flask_login import login_user
from flask_bcrypt import check_password_hash from flask_bcrypt import check_password_hash
from flask_login import login_user
from forms.loginform import LoginForm
from models.usermodel import User
def LoginUser(): def LoginUser():

25
verse/statuspengguna/registeruser.py

@ -1,22 +1,13 @@
from flask import ( from flask import flash, redirect, render_template, url_for
render_template,
redirect,
flash,
url_for,
)
from sqlalchemy.exc import (
IntegrityError,
DataError,
DatabaseError,
InterfaceError,
InvalidRequestError,
)
from werkzeug.routing import BuildError
from usermodel import User
from forms.registerform import RegisterForm
from flask_login import login_user
from flask_bcrypt import generate_password_hash from flask_bcrypt import generate_password_hash
from flask_login import login_user
from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError,
InterfaceError, InvalidRequestError)
from werkzeug.routing import BuildError
from app import db from app import db
from forms.registerform import RegisterForm
from models.usermodel import User
def RegisterUser(): def RegisterUser():

26
verse/statuspengguna/resetpassword.py

@ -1,23 +1,15 @@
from datetime import datetime from datetime import datetime
from flask import (
render_template, from flask import flash, redirect, render_template, url_for
redirect,
flash,
url_for,
)
from sqlalchemy.exc import (
IntegrityError,
DataError,
DatabaseError,
InterfaceError,
InvalidRequestError,
)
from werkzeug.routing import BuildError
from usermodel import User
from forms.resetpasswordform import ResetPasswordForm
from flask_login import login_user
from flask_bcrypt import generate_password_hash from flask_bcrypt import generate_password_hash
from flask_login import login_user
from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError,
InterfaceError, InvalidRequestError)
from werkzeug.routing import BuildError
from app import db from app import db
from forms.resetpasswordform import ResetPasswordForm
from models.usermodel import User
def ResetPassword(path): def ResetPassword(path):

12
verse/themeselector.py

@ -1,15 +1,15 @@
import os import os
import shutil import shutil
from flask import render_template from flask import render_template
from statuspengguna.helper import UserHelper
from distribusisinfo import DistribusisInfo from distribusisinfo import DistribusisInfo
from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm from forms.selectorform import SelectorForm
from forms.themeform import ThemeForm
from forms.uploadform import UploadForm
from statuspengguna.helper import UserHelper
def ThemeSelector(): def ThemeSelector():
@ -30,9 +30,7 @@ def ThemeSelector():
) )
MoveCssToUserFolder(current_distribusi, copycssfile) MoveCssToUserFolder(current_distribusi, copycssfile)
return RenderDistribusiTemplate( return RenderDistribusiTemplate(
themeform, themeform, publicthemeform, current_distribusi
publicthemeform,
current_distribusi
) )

19
verse/upload.py

@ -1,22 +1,17 @@
import os import os
import shutil import shutil
from flask import flash from flask import flash
from flask_login import current_user from flask_login import current_user
from sqlalchemy.exc import ( from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError,
IntegrityError, InterfaceError, InvalidRequestError)
InvalidRequestError,
DataError,
InterfaceError,
DatabaseError,
)
from app import db
from usermodel import User
from distribusimodel import Distribusis
from statuspengguna.helper import UserHelper from app import db
from distribusiselector import SelectCurrentDistribusi from distribusiselector import SelectCurrentDistribusi
from forms.uploadform import UploadForm from forms.uploadform import UploadForm
from models.distribusimodel import Distribusis
from models.usermodel import User
from statuspengguna.helper import UserHelper
def UploadNewDistribusi(uploadfolder): def UploadNewDistribusi(uploadfolder):

8
verse/uploadpage.py

@ -1,16 +1,14 @@
from flask import render_template from flask import render_template
from distribusiselector import SelectorVisible
from distribusisinfo import DistribusisInfo
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm
from forms.publicthemeform import PublicThemeForm from forms.publicthemeform import PublicThemeForm
from forms.selectorform import SelectorForm from forms.selectorform import SelectorForm
from forms.themeform import ThemeForm
# UserPengguna # UserPengguna
from statuspengguna.helper import UserHelper from statuspengguna.helper import UserHelper
from upload import UploadNewDistribusi, UploadUpdatedFiles from upload import UploadNewDistribusi, UploadUpdatedFiles
from distribusisinfo import DistribusisInfo
from distribusiselector import SelectorVisible
def UploadPage(uploadfolder): def UploadPage(uploadfolder):

Loading…
Cancel
Save