summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-06-18 20:15:43 +0000
committerubq323 <ubq323>2021-06-18 20:15:43 +0000
commit3f0aa4cbb7e217366c55f258fa2d4fc606498951 (patch)
tree71fb2690d2e117ffd2362cab13519f5ae2c3441e
parentfce0869042065365d40ebb9f3093e477cc71df91 (diff)
admin page with minimal things on. later once we have things, we can put other things on here.permissions
-rw-r--r--apioforum/admin.py14
-rw-r--r--apioforum/templates/admin/admin_page.html15
-rw-r--r--apioforum/templates/base.html2
3 files changed, 30 insertions, 1 deletions
diff --git a/apioforum/admin.py b/apioforum/admin.py
new file mode 100644
index 0000000..b11b735
--- /dev/null
+++ b/apioforum/admin.py
@@ -0,0 +1,14 @@
+from flask import (
+ Blueprint, render_template
+)
+from .db import get_db
+from .permissions import admin_required
+
+bp = Blueprint("admin",__name__,url_prefix="/admin")
+
+@bp.route("/")
+@admin_required
+def admin_page():
+ db = get_db()
+ admins = db.execute("select * from users where admin > 0;").fetchall()
+ return render_template("admin/admin_page.html",admins=admins)
diff --git a/apioforum/templates/admin/admin_page.html b/apioforum/templates/admin/admin_page.html
new file mode 100644
index 0000000..f48c6c0
--- /dev/null
+++ b/apioforum/templates/admin/admin_page.html
@@ -0,0 +1,15 @@
+{% extends 'base.html' %}
+{% block header %}
+<h1>{% block title %}admin page{% endblock %}</h1>
+{% endblock %}
+
+{% block content %}
+<h2>admins</h2>
+<ul>
+ {% for admin in admins %}
+ <li>{{admin.username}}</li>
+ {% endfor %}
+</ul>
+<p>this page will have more things on it later, probably</p>
+{% endblock %}
+
diff --git a/apioforum/templates/base.html b/apioforum/templates/base.html
index aae49e3..bf3748f 100644
--- a/apioforum/templates/base.html
+++ b/apioforum/templates/base.html
@@ -22,7 +22,7 @@
<p>{{ g.user }}</p>
{% if is_admin %}
- <p><a href="{{url_for('admin.adminpage')}}">admin</a></p>
+ <p><a href="{{url_for('admin.admin_page')}}">admin</a></p>
{% endif %}
<p>