diff --git a/verse/adminpage.py b/verse/adminpage.py index e69de29..b9d3f98 100644 --- a/verse/adminpage.py +++ b/verse/adminpage.py @@ -0,0 +1,35 @@ +import os +import bleach +import shutil +from flask import render_template + +from werkzeug.utils import secure_filename +from sqlalchemy.exc import ( + DataError, + DatabaseError, + InterfaceError, + InvalidRequestError, +) +from app import db + +from statuspengguna.helper import ( + IsZipUploaded, + CurrentDistribusi, + IsDistribusiLive, +) +from distribusimodel import Distribusis +from distribusisinfo import DistribusisInfo + +from forms.adminuserform import AdminUserForm +from forms.admindistribusiform import AdminDistribusiForm + + +def AdminPage(): + adminuserform = AdminUserForm() + admindistribusiform = AdminDistribusiForm() + template = render_template( + "admin.html", + adminuserform=adminuserform, + admindistribusiform=admindistribusiform, + ) + return template diff --git a/verse/forms/admindistribusiform.py b/verse/forms/admindistribusiform.py new file mode 100644 index 0000000..1e7ecaf --- /dev/null +++ b/verse/forms/admindistribusiform.py @@ -0,0 +1,12 @@ +"""Form object declaration.""" +from flask_wtf import FlaskForm +from wtforms import ( + RadioField, + SubmitField, +) + + +class AdminDistribusiForm(FlaskForm): + """Admin Distribusi form.""" + + delete = SubmitField("Delete") diff --git a/verse/forms/adminuserform.py b/verse/forms/adminuserform.py new file mode 100644 index 0000000..55a5604 --- /dev/null +++ b/verse/forms/adminuserform.py @@ -0,0 +1,13 @@ +"""Form object declaration.""" +from flask_wtf import FlaskForm +from wtforms import ( + RadioField, + SubmitField, +) + + +class AdminUserForm(FlaskForm): + """Admin Userform form.""" + update = SubmitField("update") + + delete = SubmitField("Delete") diff --git a/verse/forms/themeform.py b/verse/forms/themeform.py index 83e2029..5968f04 100644 --- a/verse/forms/themeform.py +++ b/verse/forms/themeform.py @@ -7,7 +7,7 @@ from wtforms import ( class ThemeForm(FlaskForm): - """Publication upload form.""" + """Basic theme selection form.""" theme = RadioField( "Select your theme:", diff --git a/verse/start.py b/verse/start.py index 923785c..9a2f35a 100644 --- a/verse/start.py +++ b/verse/start.py @@ -41,6 +41,7 @@ from distribusiselector import ( from editor import Editor from themeselector import ThemeSelector from upload import UploadNewDistribusi, UploadUpdatedFiles +from adminpage import AdminPage # UserPengguna from statuspengguna.helper import ( @@ -90,12 +91,14 @@ def index(): terms = uploadform.term.choices courses = uploadform.course.choices + adminuser = isadminuser() template = render_template( "index.html", distribusies=distribusies, years=years, terms=terms, courses=courses, + adminuser=adminuser, ) return template @@ -275,7 +278,7 @@ def distribusistash(path): @APP.route("/admin") @login_required def admin(): - return "admin" + return AdminPage() @APP.route("/logout") @@ -307,6 +310,13 @@ def load_user(user_id): return User.query.get(int(user_id)) +def isadminuser(): + if not current_user.is_authenticated: + return False + user = User.query.filter_by(email=current_user.email).first() + return user.admin + + if __name__ == "__main__": APP.debug = True APP.run(port=5000) diff --git a/verse/templates/admin.html b/verse/templates/admin.html new file mode 100644 index 0000000..fb6e26e --- /dev/null +++ b/verse/templates/admin.html @@ -0,0 +1,53 @@ +{% extends "base.html" %} +{% block main %} +
+