From 11a2e1c778cf4b2ea958b6bdd7868c8604d45df2 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Mon, 7 Jun 2021 13:59:24 +0530 Subject: added docstrings --- app/views/admin.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'app/views/admin.py') diff --git a/app/views/admin.py b/app/views/admin.py index 5215f02..8588e87 100644 --- a/app/views/admin.py +++ b/app/views/admin.py @@ -1,3 +1,7 @@ +# -*- coding: utf-8 -*- +""" +SuperUser/Admin portal using flask-admin +""" from app import app, login_manager, db from flask import render_template, flash, url_for, redirect import flask_login @@ -7,10 +11,20 @@ from flask_admin import Admin from flask_admin.contrib.sqla import ModelView admin = Admin(app, name="Admin", template_mode="bootstrap4") - +""" +Initialised Admin Portal +""" class ModelView(ModelView): # skipcq: PYL-E0102 + """ + Our extended ModelView Class + + Refer to Flask-Admin Docs for more details + + https://flask-admin.readthedocs.io/en/latest/introduction/?highlight=ModelView#modelview-configuration-attributes + """ def is_accessible(self): + """This function checks if a user should be given access or not""" try: if flask_login.current_user.get_role() == "SUPERUSER": return True @@ -19,4 +33,4 @@ class ModelView(ModelView): # skipcq: PYL-E0102 return False -admin.add_view(ModelView(User, db.session)) +admin.add_view(ModelView(User, db.session)) \ No newline at end of file -- cgit v1.2.3