aboutsummaryrefslogtreecommitdiff
path: root/app/views/admin.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2021-06-04 22:25:31 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2021-06-04 22:25:31 +0530
commit9104997e090d305909d139305be94c2736f90b9d (patch)
treea6bba90e4ba4e0d02b052372fca404864a7d41bc /app/views/admin.py
parente8b9b2baf80b04b66546f3b340353da4bebdfaa3 (diff)
added admin view
Diffstat (limited to 'app/views/admin.py')
-rw-r--r--app/views/admin.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/views/admin.py b/app/views/admin.py
new file mode 100644
index 0000000..b971a1a
--- /dev/null
+++ b/app/views/admin.py
@@ -0,0 +1,20 @@
+from app import app, login_manager, db
+from flask import render_template, flash,url_for, redirect
+import flask_login
+from app.models import User
+
+from flask_admin import Admin
+from flask_admin.contrib.sqla import ModelView
+
+admin = Admin(app, name="Admin", template_mode="bootstrap4")
+
+class ModelView(ModelView):
+ def is_accessible(self):
+ try:
+ if flask_login.current_user.get_role() == "SUPERUSER":
+ return True
+ return False
+ except AttributeError:
+ return False
+
+admin.add_view(ModelView(User, db.session)) \ No newline at end of file