diff --git a/advlabdb/__init__.py b/advlabdb/__init__.py
index b626b48..a3d37cb 100644
--- a/advlabdb/__init__.py
+++ b/advlabdb/__init__.py
@@ -1,5 +1,5 @@
from flask_migrate import Migrate
-from flask_security import SQLAlchemyUserDatastore
+from flask_security.datastore import SQLAlchemyUserDatastore
from .config import get_settings
from .models import db, User, Role
@@ -29,7 +29,7 @@ def create_app(create_for_server=True):
migrate.init_app(app, db)
# Setup Flask-Security-Too
- from flask_security import Security
+ from flask_security.core import Security
Security(app, user_datastore)
diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py
index 93a397e..ab3ed99 100644
--- a/advlabdb/adminModelViews.py
+++ b/advlabdb/adminModelViews.py
@@ -10,7 +10,9 @@ from flask_admin.contrib.sqla.fields import QuerySelectField, QuerySelectMultipl
from flask_admin.contrib.sqla.filters import BooleanEqualFilter, FilterEqual
from flask_admin.helpers import get_form_data
from flask_admin.menu import MenuLink
-from flask_security import admin_change_password, current_user, hash_password
+from flask_login import current_user
+from flask_security.changeable import admin_change_password
+from flask_security.utils import hash_password
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField, FileRequired
from matplotlib.figure import Figure
@@ -366,6 +368,7 @@ class SemesterView(SecureAdminModelView):
transferAssistants=form.transfer_assistants.data,
)
+ @staticmethod
def addMenuLink(space, newSemester):
categoryText = "Active semester"
link = MenuLink(
diff --git a/advlabdb/advlabdb_independent_funs.py b/advlabdb/advlabdb_independent_funs.py
index a52285c..381f62f 100644
--- a/advlabdb/advlabdb_independent_funs.py
+++ b/advlabdb/advlabdb_independent_funs.py
@@ -10,7 +10,7 @@ def flashRandomPassword(email: str, password: str):
flash(f"New random password for email {email}: {password}", category="warning")
-def deep_getattr(object, composed_name):
+def deep_getattr(object, composed_name: str):
names = composed_name.split(".")
attr = getattr(object, names[0])
for name in names[1:]:
@@ -19,7 +19,7 @@ def deep_getattr(object, composed_name):
return attr
-def str_without_semester_formatter(view, context, model, name):
+def str_without_semester_formatter(view, context, model, name: str):
attr = deep_getattr(model, name)
if attr is None:
@@ -32,7 +32,7 @@ def str_without_semester_formatter(view, context, model, name):
return attr.str_without_semester()
-def str_formatter(view, context, model, name):
+def str_formatter(view, context, model, name: str):
attr = deep_getattr(model, name)
if attr is None:
@@ -53,7 +53,7 @@ def _default_attr_formatter(attr):
return attr
-def link_formatter(model, name, endpoint, attr_formatter=_default_attr_formatter):
+def link_formatter(model, name: str, endpoint, attr_formatter=_default_attr_formatter):
attr = deep_getattr(model, name)
if attr is None:
@@ -77,7 +77,7 @@ def link_formatter_factory(endpoint, attr_formatter=_default_attr_formatter):
return formatter
-def email_formatter(view, context, model, name):
+def email_formatter(view, context, model, name: str):
attr = deep_getattr(model, name)
if attr is None:
@@ -86,7 +86,7 @@ def email_formatter(view, context, model, name):
return Markup(f"{escape(attr)}")
-def experiment_marks_missing_formatter(view, context, model, name):
+def experiment_marks_missing_formatter(view, context, model, name: str):
experiment_marks_missing = getattr(model, name)
if experiment_marks_missing is True:
return Markup("Yes")
diff --git a/advlabdb/assistantModelViews.py b/advlabdb/assistantModelViews.py
index 10bd04f..910e7b0 100644
--- a/advlabdb/assistantModelViews.py
+++ b/advlabdb/assistantModelViews.py
@@ -2,7 +2,8 @@ from flask import flash, redirect, request, url_for
from flask_admin import Admin as FlaskAdmin
from flask_admin import expose
from flask_admin.model.template import EndpointLinkRowAction
-from flask_security import admin_change_password, current_user
+from flask_login import current_user
+from flask_security.changeable import admin_change_password
from flask_wtf import FlaskForm
from .advlabdb_independent_funs import (
diff --git a/advlabdb/custom_classes.py b/advlabdb/custom_classes.py
index 7d94bf8..3232cbd 100644
--- a/advlabdb/custom_classes.py
+++ b/advlabdb/custom_classes.py
@@ -3,7 +3,7 @@ from flask_admin import AdminIndexView, BaseView, expose
from flask_admin.contrib.sqla import ModelView
from flask_admin.helpers import get_form_data
from flask_admin.model.helpers import get_mdict_item_or_list
-from flask_security import current_user
+from flask_login import current_user
from sqlalchemy import select
from .exceptions import DatabaseException, ModelViewException
diff --git a/advlabdb/database_import.py b/advlabdb/database_import.py
index 8ae126f..29974de 100644
--- a/advlabdb/database_import.py
+++ b/advlabdb/database_import.py
@@ -73,8 +73,6 @@ def importFromFile(filePath):
expectingTable = True
readHeader = False
- activeDict = None
-
for line in f:
line = line[:-1]
diff --git a/advlabdb/model_dependent_funs.py b/advlabdb/model_dependent_funs.py
index 7467fc9..302ba59 100644
--- a/advlabdb/model_dependent_funs.py
+++ b/advlabdb/model_dependent_funs.py
@@ -6,7 +6,7 @@ from functools import cache
from flask import flash
from flask_admin.menu import MenuLink
-from flask_security import current_user
+from flask_login import current_user
from wtforms.fields import BooleanField, IntegerField, SelectField, StringField
from wtforms.validators import DataRequired, NumberRange, Optional
diff --git a/advlabdb/models.py b/advlabdb/models.py
index 4154e7c..9a34848 100644
--- a/advlabdb/models.py
+++ b/advlabdb/models.py
@@ -9,7 +9,7 @@ https://flask-sqlalchemy.palletsprojects.com/en/2.x/models/
from decimal import ROUND_HALF_UP, Decimal
from flask import flash
-from flask_security import current_user
+from flask_login import current_user
from flask_security.models import fsqla_v2 as fsqla
from flask_security.models.fsqla_v2 import FsRoleMixin, FsUserMixin
from flask_sqlalchemy import SQLAlchemy
@@ -253,6 +253,7 @@ class GroupExperiment(db.Model):
def __str__(self):
return self.str()
+ @staticmethod
def check(semester_experiment, group):
for partStudent in group.part_students:
student = partStudent.student
diff --git a/advlabdb/routes.py b/advlabdb/routes.py
index 86635a9..01fb9ba 100644
--- a/advlabdb/routes.py
+++ b/advlabdb/routes.py
@@ -1,5 +1,6 @@
from flask import Blueprint, flash, redirect, request, url_for
-from flask_security import auth_required, current_user
+from flask_login import current_user
+from flask_security.decorators import auth_required
from .model_dependent_funs import active_semester_str
from .models import Semester, db
diff --git a/cli/maintain/reset_admin_password.py b/cli/maintain/reset_admin_password.py
index 5030e10..aad96b7 100644
--- a/cli/maintain/reset_admin_password.py
+++ b/cli/maintain/reset_admin_password.py
@@ -1,5 +1,5 @@
import click
-from flask_security import admin_change_password
+from flask_security.changeable import admin_change_password
from sqlalchemy import select
from advlabdb import create_app
diff --git a/cli/setup/init_db.py b/cli/setup/init_db.py
index 7e77a99..94661cd 100644
--- a/cli/setup/init_db.py
+++ b/cli/setup/init_db.py
@@ -2,7 +2,7 @@ from pathlib import Path
import click
from email_validator import validate_email
-from flask_security import hash_password
+from flask_security.utils import hash_password
from advlabdb import create_app, settings, user_datastore
from advlabdb.model_independent_funs import randomPassword
diff --git a/cli/test/generate_test_db.py b/cli/test/generate_test_db.py
index 09e28ed..67ea9f6 100644
--- a/cli/test/generate_test_db.py
+++ b/cli/test/generate_test_db.py
@@ -7,7 +7,7 @@ from test.experiment_titles import experiment_titles
from test.student_names import student_names
import click
-from flask_security import hash_password
+from flask_security.utils import hash_password
from advlabdb import create_app, settings, user_datastore
from advlabdb.exceptions import DatabaseException
diff --git a/poetry.lock b/poetry.lock
index 997a8fc..c1fd61a 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -506,7 +506,7 @@ email = ["email-validator"]
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
-content-hash = "62210a57e60dcbadfb408e2ee9a59e77ccc9c9a4b2e1944f61885d1e53a4cef5"
+content-hash = "6c1039990219b6759baf90fddf5ec81ffc800dc3497f32f119fbb66f6f4b2562"
[metadata.files]
alembic = [
diff --git a/pyproject.toml b/pyproject.toml
index c0b5872..9522a2e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -12,9 +12,10 @@ click = ">=8.1.3"
email-validator = ">=1.2.1"
flask = ">=2.2.2"
flask-admin = ">=1.6.0"
+flask-login = ">=0.6.2"
flask-migrate = ">=3.1.0"
-flask-sqlalchemy = ">=2.5.1"
flask-security-Too = ">=4.1.5"
+flask-sqlalchemy = ">=2.5.1"
flask-wtf = ">=1.0.1"
gunicorn = ">=20.1.0"
markupsafe = ">=2.1.1"