forked from crunk/distribusi-verse
sort, format and move models to folder
This commit is contained in:
parent
dca9666984
commit
9e48758767
@ -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():
|
||||||
|
@ -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():
|
||||||
|
@ -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"
|
||||||
|
@ -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()
|
||||||
|
@ -1,28 +1,22 @@
|
|||||||
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 distribusimodel import Distribusis
|
|
||||||
from distribusisinfo import DistribusisInfo
|
|
||||||
|
|
||||||
from forms.selectorform import SelectorForm
|
|
||||||
from forms.uploadform import UploadForm
|
|
||||||
from forms.distribusiform import DistribusiForm
|
|
||||||
from forms.themeform import ThemeForm
|
|
||||||
from forms.publicthemeform import PublicThemeForm
|
|
||||||
|
|
||||||
# UserPengguna
|
|
||||||
from statuspengguna.helper import UserHelper
|
|
||||||
|
|
||||||
from app import db
|
from app import db
|
||||||
|
from distribusisinfo import DistribusisInfo
|
||||||
|
from forms.distribusiform import DistribusiForm
|
||||||
|
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
|
||||||
|
from statuspengguna.helper import UserHelper
|
||||||
|
|
||||||
|
|
||||||
def DistribusiSelector():
|
def DistribusiSelector():
|
||||||
|
@ -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:
|
||||||
|
@ -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
|
|
||||||
from distribusimodel import Distribusis
|
|
||||||
|
|
||||||
# UserPengguna
|
|
||||||
from statuspengguna.helper import UserHelper
|
|
||||||
from distribusiselector import SelectorVisible
|
|
||||||
|
|
||||||
# Forms!
|
|
||||||
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
|
|
||||||
|
|
||||||
from distribusisinfo import DistribusisInfo
|
|
||||||
|
|
||||||
# Tada!
|
# Tada!
|
||||||
from distribusi.cli import build_argparser
|
from distribusi.cli import build_argparser
|
||||||
from distribusi.distribusi import distribusify
|
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)
|
||||||
|
|
||||||
|
from app import db
|
||||||
|
from distribusiselector import SelectorVisible
|
||||||
|
from distribusisinfo import DistribusisInfo
|
||||||
|
from forms.distribusiform import DistribusiForm
|
||||||
|
from forms.publicthemeform import PublicThemeForm
|
||||||
|
from forms.selectorform import SelectorForm
|
||||||
|
from forms.themeform import ThemeForm
|
||||||
|
# Forms!
|
||||||
|
from forms.uploadform import UploadForm
|
||||||
|
from models.distribusimodel import Distribusis
|
||||||
|
from models.usermodel import User
|
||||||
|
# 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:
|
||||||
|
@ -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 app import db
|
||||||
from distribusimodel import Distribusis
|
|
||||||
|
|
||||||
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.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}")
|
||||||
|
@ -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}",
|
||||||
|
@ -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}",
|
||||||
|
@ -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):
|
||||||
|
@ -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):
|
||||||
|
@ -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):
|
||||||
|
@ -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):
|
||||||
|
@ -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(
|
||||||
|
@ -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):
|
||||||
|
@ -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):
|
||||||
|
@ -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):
|
||||||
|
@ -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:",
|
||||||
|
@ -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
Normal file
23
verse/models/distribusimodel.py
Normal file
@ -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
Normal file
23
verse/models/usermodel.py
Normal file
@ -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
|
@ -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(","),
|
||||||
}
|
}
|
||||||
|
@ -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):
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
import os
|
import os
|
||||||
from flask_login import current_user
|
|
||||||
from flask import flash
|
|
||||||
from sqlalchemy.exc import (
|
|
||||||
DataError,
|
|
||||||
DatabaseError,
|
|
||||||
InterfaceError,
|
|
||||||
InvalidRequestError,
|
|
||||||
)
|
|
||||||
|
|
||||||
from usermodel import User
|
from flask import flash
|
||||||
from distribusimodel import Distribusis
|
from flask_login import current_user
|
||||||
from distribusisinfo import DistribusisInfo
|
from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError,
|
||||||
|
InvalidRequestError)
|
||||||
|
|
||||||
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:
|
||||||
|
@ -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():
|
||||||
|
@ -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():
|
||||||
|
@ -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):
|
||||||
|
@ -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
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -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 app import db
|
||||||
|
|
||||||
from usermodel import User
|
|
||||||
from distribusimodel import Distribusis
|
|
||||||
|
|
||||||
from statuspengguna.helper import UserHelper
|
|
||||||
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):
|
||||||
|
@ -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…
Reference in New Issue
Block a user