1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Split utils.py

This commit is contained in:
Mo 2022-04-18 18:04:17 +02:00
parent 3688bfc0ea
commit 11746b8c67
6 changed files with 32 additions and 23 deletions

View file

@ -38,7 +38,15 @@ from advlabdb.customClasses import (
SecureAdminModelView,
)
from advlabdb.database_import import importFromFile
from advlabdb.dependent_funs import (
flashRandomPassword,
initActiveSemesterMenuLinks,
setUserActiveSemester,
sortedSemestersStartingWithNewest,
userActiveSemester,
)
from advlabdb.exceptions import DataBaseException, ModelViewException
from advlabdb.independent_funs import randomPassword
from advlabdb.models import (
MAX_MARK,
MIN_MARK,
@ -58,14 +66,6 @@ from advlabdb.models import (
Student,
User,
)
from advlabdb.utils import (
flashRandomPassword,
initActiveSemesterMenuLinks,
randomPassword,
setUserActiveSemester,
sortedSemestersStartingWithNewest,
userActiveSemester,
)
def semesterExperimentQueryFactory():

View file

@ -9,7 +9,13 @@ from wtforms.validators import NumberRange
from advlabdb import assistantSpace, db
from advlabdb.customClasses import SecureAssistantBaseView, SecureAssistantModelView
from advlabdb.dependent_funs import (
flashRandomPassword,
initActiveSemesterMenuLinks,
userActiveSemester,
)
from advlabdb.exceptions import DataBaseException, ModelViewException
from advlabdb.independent_funs import randomPassword
from advlabdb.models import (
MAX_MARK,
MIN_MARK,
@ -28,12 +34,6 @@ from advlabdb.models import (
Student,
User,
)
from advlabdb.utils import (
flashRandomPassword,
initActiveSemesterMenuLinks,
randomPassword,
userActiveSemester,
)
class AssistantAppointmentView(SecureAssistantModelView):

View file

@ -6,6 +6,7 @@ from flask_admin.model.template import EndpointLinkRowAction
from flask_security import current_user
from sqlalchemy import and_
from advlabdb.dependent_funs import reportBadAttempt, userActiveSemester
from advlabdb.exceptions import DataBaseException, ModelViewException
from advlabdb.models import (
Assistant,
@ -15,7 +16,6 @@ from advlabdb.models import (
PartStudent,
SemesterExperiment,
)
from advlabdb.utils import reportBadAttempt, userActiveSemester
def adminViewIsAccessible():

View file

@ -1,6 +1,3 @@
from random import choice
from string import ascii_letters, digits
from flask import flash, url_for
from flask_admin.menu import MenuLink
from flask_security import current_user
@ -9,10 +6,6 @@ from advlabdb import app, db
from advlabdb.models import Semester
def randomPassword():
return "".join(choice(ascii_letters + digits) for i in range(12))
def flashRandomPassword(password):
flash(f"Random password: {password}", category="warning")

View file

@ -0,0 +1,16 @@
from random import choice
from string import ascii_letters, digits
def parse_bool(str):
str_lower = str.lower()
if str_lower == "false":
return False
elif str_lower == "true":
return True
else:
raise (ValueError(f'Can not parse a bool from "{str}"'))
def randomPassword():
return "".join(choice(ascii_letters + digits) for i in range(12))

View file

@ -2,7 +2,7 @@ from flask import flash, redirect, render_template, request, url_for
from flask_security import auth_required, current_user, roles_accepted, roles_required
from advlabdb import app
from advlabdb.utils import setUserActiveSemester, userActiveSemester
from advlabdb.dependent_funs import setUserActiveSemester, userActiveSemester
@app.context_processor