mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Cleaned up with flake8
This commit is contained in:
parent
810a3ba496
commit
64fe85272b
7 changed files with 16 additions and 17 deletions
|
@ -19,8 +19,8 @@ db = SQLAlchemy(app)
|
||||||
|
|
||||||
fsqla.FsModels.set_db_info(db)
|
fsqla.FsModels.set_db_info(db)
|
||||||
|
|
||||||
app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = False #DEBUG
|
# app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = False # DEBUG
|
||||||
DebugToolbarExtension(app) #DEBUG
|
# DebugToolbarExtension(app) # DEBUG
|
||||||
|
|
||||||
from advlabdb import customClasses
|
from advlabdb import customClasses
|
||||||
admin = Admin(app,
|
admin = Admin(app,
|
||||||
|
@ -35,5 +35,4 @@ user_datastore = SQLAlchemyUserDatastore(db, models.User, models.Role)
|
||||||
Security(app, user_datastore)
|
Security(app, user_datastore)
|
||||||
|
|
||||||
from advlabdb import routes
|
from advlabdb import routes
|
||||||
from advlabdb import forms
|
|
||||||
from advlabdb import modelViews
|
from advlabdb import modelViews
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
from flask_admin import AdminIndexView
|
from flask_admin import AdminIndexView
|
||||||
from flask_security import current_user
|
from flask_security import current_user
|
||||||
from flask import flash
|
|
||||||
from flask_admin.contrib.sqla import ModelView
|
from flask_admin.contrib.sqla import ModelView
|
||||||
|
|
||||||
from advlabdb.utils import userActiveSemester
|
|
||||||
|
|
||||||
|
|
||||||
def adminViewIsAccessible():
|
def adminViewIsAccessible():
|
||||||
return current_user.has_role("admin")
|
return current_user.has_role("admin")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from flask import url_for, render_template, flash, request
|
from flask import url_for, flash, request
|
||||||
from flask_admin.menu import MenuLink
|
from flask_admin.menu import MenuLink
|
||||||
from flask_admin.contrib.sqla.filters import BaseSQLAFilter
|
from flask_admin.contrib.sqla.filters import BaseSQLAFilter
|
||||||
from flask_security import hash_password
|
from flask_security import hash_password
|
||||||
|
@ -6,9 +6,9 @@ from wtforms import BooleanField, SelectField, TextField
|
||||||
from wtforms.validators import DataRequired, Email
|
from wtforms.validators import DataRequired, Email
|
||||||
|
|
||||||
from advlabdb import admin, app, user_datastore, db
|
from advlabdb import admin, app, user_datastore, db
|
||||||
from advlabdb.models import *
|
|
||||||
from advlabdb.utils import randomPassword, userActiveSemester, partFromLabelInUserActiveSemester
|
from advlabdb.utils import randomPassword, userActiveSemester, partFromLabelInUserActiveSemester
|
||||||
from advlabdb.customClasses import SecureModelView
|
from advlabdb.customClasses import SecureModelView
|
||||||
|
from advlabdb.models import User, Role, Semester, Part, Student, PartStudent, Group, GroupExperiment, Experiment, Assistant, Appointment, PartExperiment, ExperimentMark
|
||||||
|
|
||||||
partsLabels = ["A/1", "A/2", "A/m", "B/1", "B/2"]
|
partsLabels = ["A/1", "A/2", "A/m", "B/1", "B/2"]
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import json
|
from advlabdb import app, db
|
||||||
from advlabdb import app, user_datastore
|
|
||||||
from flask import render_template, request, url_for, flash, redirect
|
from flask import render_template, request, url_for, flash, redirect
|
||||||
from flask_security import auth_required, roles_required, hash_password, current_user
|
from flask_security import auth_required, current_user
|
||||||
|
|
||||||
from advlabdb.utils import *
|
from advlabdb.utils import titleToTemplate, userActiveSemester
|
||||||
from advlabdb.models import *
|
from advlabdb.models import Semester
|
||||||
from advlabdb.forms import *
|
|
||||||
|
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
|
@ -63,6 +61,7 @@ def index():
|
||||||
else:
|
else:
|
||||||
return render_template("index.html")
|
return render_template("index.html")
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@app.route("/assistants")
|
@app.route("/assistants")
|
||||||
@roles_required("admin")
|
@roles_required("admin")
|
||||||
|
@ -163,6 +162,7 @@ def deactivate_users():
|
||||||
return redirect(url_for("users"))
|
return redirect(url_for("users"))
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@app.route("/set_semester", methods=["GET"])
|
@app.route("/set_semester", methods=["GET"])
|
||||||
@auth_required()
|
@auth_required()
|
||||||
def set_semester():
|
def set_semester():
|
||||||
|
|
|
@ -6,6 +6,7 @@ from flask import flash
|
||||||
from advlabdb.models import Semester
|
from advlabdb.models import Semester
|
||||||
from advlabdb import db
|
from advlabdb import db
|
||||||
|
|
||||||
|
|
||||||
def makeTable(headerAndDataList, rows, tableId="table"):
|
def makeTable(headerAndDataList, rows, tableId="table"):
|
||||||
def cellString(cell):
|
def cellString(cell):
|
||||||
cell = str(cell)
|
cell = str(cell)
|
||||||
|
|
|
@ -2,6 +2,7 @@ from os.path import exists
|
||||||
from shutil import copytree, rmtree
|
from shutil import copytree, rmtree
|
||||||
from flask_admin import __file__ as flaskAdminPath
|
from flask_admin import __file__ as flaskAdminPath
|
||||||
|
|
||||||
|
|
||||||
def copyAdminTemplates():
|
def copyAdminTemplates():
|
||||||
src = flaskAdminPath.removesuffix("__init__.py") + "templates/bootstrap3/admin"
|
src = flaskAdminPath.removesuffix("__init__.py") + "templates/bootstrap3/admin"
|
||||||
if not exists(src):
|
if not exists(src):
|
||||||
|
@ -25,6 +26,7 @@ def copyAdminTemplates():
|
||||||
print("Copied", src, "->", dist)
|
print("Copied", src, "->", dist)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if copyAdminTemplates():
|
if copyAdminTemplates():
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
|
Loading…
Reference in a new issue