2017-07-06 23:35:08 +02:00
|
|
|
from flask import Blueprint, url_for, redirect, session, render_template
|
|
|
|
from functools import wraps
|
2017-07-22 04:06:45 +02:00
|
|
|
from titanembeds.database import get_administrators_list
|
2017-07-06 23:35:08 +02:00
|
|
|
|
|
|
|
admin = Blueprint("admin", __name__)
|
|
|
|
|
|
|
|
def is_admin(f):
|
|
|
|
def decorator(f):
|
|
|
|
@wraps(f)
|
|
|
|
def decorated_function(*args, **kwargs):
|
|
|
|
if 'user_id' not in session:
|
|
|
|
return redirect(url_for("index"))
|
2017-07-22 04:06:45 +02:00
|
|
|
if session['user_id'] not in get_administrators_list():
|
2017-07-06 23:35:08 +02:00
|
|
|
return redirect(url_for("index"))
|
|
|
|
return f(*args, **kwargs)
|
|
|
|
return decorated_function
|
|
|
|
return decorator(f)
|
|
|
|
|
|
|
|
@admin.route("/")
|
|
|
|
@is_admin
|
|
|
|
def index():
|
|
|
|
return render_template("admin_index.html.j2")
|