admin page without functionality
This commit is contained in:
parent
fb5c4bac27
commit
847f4b234d
@ -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
|
12
verse/forms/admindistribusiform.py
Normal file
12
verse/forms/admindistribusiform.py
Normal file
@ -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")
|
13
verse/forms/adminuserform.py
Normal file
13
verse/forms/adminuserform.py
Normal file
@ -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")
|
@ -7,7 +7,7 @@ from wtforms import (
|
||||
|
||||
|
||||
class ThemeForm(FlaskForm):
|
||||
"""Publication upload form."""
|
||||
"""Basic theme selection form."""
|
||||
|
||||
theme = RadioField(
|
||||
"Select your theme:",
|
||||
|
@ -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)
|
||||
|
53
verse/templates/admin.html
Normal file
53
verse/templates/admin.html
Normal file
@ -0,0 +1,53 @@
|
||||
{% extends "base.html" %}
|
||||
{% block main %}
|
||||
<div id="buttons">
|
||||
{% if not current_user.is_authenticated %}
|
||||
<div class="signin">
|
||||
<a href="/login">
|
||||
<input type="button" name="button" value="Sign in"></input>
|
||||
</a>
|
||||
</div>
|
||||
<div class="signin">
|
||||
<a href="/register">
|
||||
<input type="button" name="button" value="Register"></input>
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="distribusi">
|
||||
<a href="/distribusi">
|
||||
<input type="button" name="button" value="Distribusi"></input>
|
||||
</a>
|
||||
</div>
|
||||
<div class="logout">
|
||||
<a href="/logout">
|
||||
<input type="button" name="button" value="Logout"></input>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="maincontent">
|
||||
<!-- a div with all the distribusis listed in the distribusiverse -->
|
||||
<div id="distribusiverse" class="maincontent">
|
||||
<h2>List of distribusis</h2>
|
||||
<form method="POST" enctype="multipart/form-data" action="{{ url_for('theme') }}">
|
||||
{{ admindistribusiform.csrf_token }}
|
||||
<fieldset class="button required multiselect delete">
|
||||
{{ admindistribusiform.delete }}
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="distribusiverse" class="maincontent">
|
||||
<h2>List of users</h2>
|
||||
<form method="POST" enctype="multipart/form-data" action="{{ url_for('theme') }}">
|
||||
{{ adminuserform.csrf_token }}
|
||||
<fieldset class="button required multiselect update">
|
||||
{{ adminuserform.update }}
|
||||
</fieldset>
|
||||
<fieldset class="button required multiselect delete">
|
||||
{{ adminuserform.delete }}
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
@ -24,6 +24,13 @@
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if adminuser %}
|
||||
<div class="admin">
|
||||
<a href="/admin">
|
||||
<input type="button" name="button" value="Admin"></input>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if current_user.is_authenticated %}
|
||||
<h2 id="fancyboi"> Hi {{ current_user.email }}!</h2>
|
||||
|
Loading…
Reference in New Issue
Block a user