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

Black and isort

This commit is contained in:
Mo 2022-02-13 19:58:05 +01:00
parent 0b5dcfb460
commit 6e45c91d45
4 changed files with 29 additions and 28 deletions

View file

@ -1,23 +1,25 @@
from flask import flash, request, url_for, redirect
from pathlib import Path
from flask import flash, redirect, request, url_for
from flask_admin import expose
from flask_admin.contrib.sqla.fields import QuerySelectField, QuerySelectMultipleField
from flask_admin.contrib.sqla.filters import BaseSQLAFilter
from flask_admin.helpers import get_form_data
from flask_admin.menu import MenuLink
from flask_admin.model.template import EndpointLinkRowAction
from flask_admin import expose
from flask_security import admin_change_password, current_user, hash_password
from sqlalchemy import func, or_, and_
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField, FileRequired
from sqlalchemy import and_, func, or_
from werkzeug.utils import secure_filename
from wtforms import BooleanField, Form, RadioField, SelectField, StringField
from wtforms.fields import DateField, IntegerField
from wtforms.validators import URL, DataRequired, Email, NumberRange, Optional
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired, FileAllowed
from werkzeug.utils import secure_filename
from pathlib import Path
from advlabdb import adminSpace, app, assistantSpace, db, user_datastore
from advlabdb.configUtils import getConfig
from advlabdb.customClasses import SecureAdminModelView, SecureAdminBaseView
from advlabdb.customClasses import SecureAdminBaseView, SecureAdminModelView
from advlabdb.database_import import importFromFile
from advlabdb.exceptions import DataBaseException, ModelViewException
from advlabdb.models import (
Appointment,
@ -41,7 +43,6 @@ from advlabdb.utils import (
setUserActiveSemester,
userActiveSemester,
)
from advlabdb.database_import import importFromFile
def semesterExperimentQueryFactory():
@ -186,7 +187,7 @@ class UserView(SecureAdminModelView):
if not is_created:
if model == current_user:
if not form.active.data:
raise ModelViewException("Tried to deactiavte yourself as user!")
raise ModelViewException("Tried to deactivate yourself as user!")
if not model.has_role("admin"):
raise ModelViewException("Tried to remove your admin role!")
@ -246,7 +247,7 @@ class SemesterView(SecureAdminModelView):
)
transfer_assistants = BooleanField(
"Transfer Assistants",
description="This option transfers assistants of your active semester to active experiments in the new semester. Make sure that your semester is the last semester before creating a new one (recommended)! Active experiments are transfered anyway. If you do not want an experiment to be transfered, set it to inactive before creating the new semester. Experiments which are switched to active before creating the new semester will be created in the new semester without assistants. It is important to check the assistants of all experiments after creating a new semester.",
description="This option transfers assistants of your active semester to active experiments in the new semester. Make sure that your semester is the last semester before creating a new one (recommended)! Active experiments are transferred anyway. If you do not want an experiment to be transferred, set it to inactive before creating the new semester. Experiments which are switched to active before creating the new semester will be created in the new semester without assistants. It is important to check the assistants of all experiments after creating a new semester.",
default=True,
)
@ -873,7 +874,7 @@ class ExperimentMarkView(SecureAdminModelView):
column_default_sort = [("oral_mark", False), ("protocol_mark", False)]
"""
# Deactivated for the experiments hisotry of a student.
# Deactivated for the experiments history of a student.
def queryFilter(self):
return ExperimentMark.group_experiment.has(
GroupExperiment.semester_experiment.has(SemesterExperiment.semester == userActiveSemester())

View file

@ -1,23 +1,24 @@
from flask import has_request_context, flash
from datetime import datetime
from shutil import copy2
from flask import flash, has_request_context
from advlabdb import app, db
from advlabdb.exceptions import DataBaseImportException
from advlabdb.models import (
Part,
Student,
Group,
PartStudent,
Experiment,
GroupExperiment,
Appointment,
Semester,
Program,
SemesterExperiment,
Assistant,
Experiment,
Group,
GroupExperiment,
Part,
PartStudent,
Program,
Semester,
SemesterExperiment,
Student,
User,
)
from advlabdb.exceptions import DataBaseImportException
def importFromFile(filePath):

View file

@ -6,13 +6,12 @@ For more information about the implementation, see the part to Models in the doc
https://flask-sqlalchemy.palletsprojects.com/en/2.x/models/
"""
# Imports
from decimal import ROUND_HALF_UP, Decimal
from flask import flash
from flask_security import current_user
from flask_security.models.fsqla_v2 import FsRoleMixin, FsUserMixin
from decimal import Decimal, ROUND_HALF_UP
# Importing the database instance
from advlabdb import db
from advlabdb.configUtils import getConfig
from advlabdb.exceptions import DataBaseException

View file

@ -1,5 +1,5 @@
from flask import flash, redirect, render_template, request, url_for
from flask_security import auth_required, current_user, roles_required, roles_accepted
from flask_security import auth_required, current_user, roles_accepted, roles_required
from advlabdb import app
from advlabdb.utils import setUserActiveSemester, userActiveSemester