mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-02 22:33:05 +00:00
is comparisons don't work with sqlalchemy! I love that silence ignorance!!! Not even a warning… Please, if you read this, consider rewriting in Rust and avoid ORMs.
This commit is contained in:
parent
7bbf0b861b
commit
99cc109cde
9 changed files with 21 additions and 19 deletions
|
@ -43,9 +43,9 @@ def deactivate_assistants():
|
|||
user_ids_to_deactivate = db.session.scalars(
|
||||
select(Assistant.user_id)
|
||||
.join(User)
|
||||
.where(User.active is True)
|
||||
.where(User.active == True)
|
||||
.except_(
|
||||
select(Assistant.user_id).join(Assistant.semester_experiments).join(Semester).where(Semester.done is False)
|
||||
select(Assistant.user_id).join(Assistant.semester_experiments).join(Semester).where(Semester.done == False)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -636,14 +636,14 @@ class GroupView(SecureAdminModelView):
|
|||
if is_created:
|
||||
|
||||
def query_factory():
|
||||
return partStudentQueryFactory().where(PartStudent.group is None)
|
||||
return partStudentQueryFactory().where(PartStudent.group == None)
|
||||
|
||||
else:
|
||||
|
||||
def query_factory():
|
||||
return partStudentQueryFactory().where(
|
||||
or_(
|
||||
and_(PartStudent.group is None, Part.program == group.program),
|
||||
and_(PartStudent.group == None, Part.program == group.program),
|
||||
PartStudent.group == group,
|
||||
)
|
||||
)
|
||||
|
@ -754,7 +754,7 @@ class ExperimentView(SecureAdminModelView):
|
|||
|
||||
|
||||
def assistantQueryFactory():
|
||||
return Assistant.query.join(User).where(User.active is True)
|
||||
return Assistant.query.join(User).where(User.active == True)
|
||||
|
||||
|
||||
def weighting_field(label: str, default: float):
|
||||
|
@ -776,7 +776,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
|||
class CreateForm(FlaskForm):
|
||||
@staticmethod
|
||||
def experimentQueryFactory():
|
||||
return Experiment.query.where(Experiment.active is True)
|
||||
return Experiment.query.where(Experiment.active == True)
|
||||
|
||||
experiment = QuerySelectField(
|
||||
"Experiment",
|
||||
|
@ -937,7 +937,7 @@ class ExperimentRowFilter(FilterEqual):
|
|||
if not has_request_context():
|
||||
return ()
|
||||
|
||||
activeExperiments = db.session.scalars(select(Experiment).where(Experiment.active is True))
|
||||
activeExperiments = db.session.scalars(select(Experiment).where(Experiment.active == True))
|
||||
return tuple(
|
||||
(
|
||||
f"{activeExperiment.number},{activeExperiment.program_id}",
|
||||
|
@ -1193,7 +1193,7 @@ class ExperimentMarkView(SecureAdminModelView):
|
|||
if not has_request_context():
|
||||
return ()
|
||||
|
||||
admins = db.session.scalars(select(Admin).join(User).where(User.active is True))
|
||||
admins = db.session.scalars(select(Admin).join(User).where(User.active == True))
|
||||
return tuple((admin.id, str(admin)) for admin in admins)
|
||||
|
||||
def apply(self, query, value, alias=None):
|
||||
|
|
|
@ -88,7 +88,7 @@ def email_formatter(view, context, model, name: str):
|
|||
|
||||
def experiment_marks_missing_formatter(view, context, model, name: str):
|
||||
experiment_marks_missing = getattr(model, name)
|
||||
if experiment_marks_missing is True:
|
||||
if experiment_marks_missing == True:
|
||||
return Markup("<span style='color: red;'>Yes</span>")
|
||||
|
||||
return "No"
|
||||
|
|
|
@ -77,7 +77,7 @@ def mark_hists(markType, active_assistants):
|
|||
|
||||
|
||||
def assistant_marks_analysis(cls):
|
||||
active_assistants = db.session.scalars(select(Assistant).join(User).where(User.active is True)).all()
|
||||
active_assistants = db.session.scalars(select(Assistant).join(User).where(User.active == True)).all()
|
||||
|
||||
if not active_assistants:
|
||||
flash("No active assistants!", "warning")
|
||||
|
|
|
@ -211,7 +211,7 @@ class AssistantUserView(SecureAssistantModelView):
|
|||
@staticmethod
|
||||
def semesterQueryFactory():
|
||||
# Show only last two semesters to assistants
|
||||
return Semester.query.order_by(Semester.id.desc()).where(Semester.done is False).limit(2)
|
||||
return Semester.query.order_by(Semester.id.desc()).where(Semester.done == False).limit(2)
|
||||
|
||||
active_semester = QuerySelectField(
|
||||
"Active Semester",
|
||||
|
|
|
@ -44,9 +44,9 @@ class SecureAdminIndexView(CustomIndexView):
|
|||
.join(Assistant.semester_experiments)
|
||||
.where(SemesterExperiment.semester == current_user.active_semester)
|
||||
.join(SemesterExperiment.group_experiments)
|
||||
.where(GroupExperiment.experiment_marks_missing is True)
|
||||
.where(GroupExperiment.experiment_marks_missing == True)
|
||||
.join(GroupExperiment.experiment_marks)
|
||||
.where(ExperimentMark.final_experiment_mark is None)
|
||||
.where(ExperimentMark.final_experiment_mark == None)
|
||||
.group_by(Assistant.id)
|
||||
.order_by(func.count().desc())
|
||||
)
|
||||
|
@ -71,7 +71,7 @@ class SecureAssistantIndexView(CustomIndexView):
|
|||
.where(SemesterExperiment.semester == current_user.active_semester)
|
||||
.join(SemesterExperiment.assistants)
|
||||
.where(Assistant.user == current_user)
|
||||
.where(ExperimentMark.final_experiment_mark is None)
|
||||
.where(ExperimentMark.final_experiment_mark == None)
|
||||
)
|
||||
|
||||
return self.render(
|
||||
|
@ -158,7 +158,7 @@ class CustomModelView(ModelView):
|
|||
|
||||
def update_model(self, form, model):
|
||||
try:
|
||||
if self.customUpdateModel(form, model) is False:
|
||||
if self.customUpdateModel(form, model) == False:
|
||||
# Nothing changed
|
||||
return True
|
||||
|
||||
|
|
|
@ -537,7 +537,7 @@ class Semester(db.Model):
|
|||
if transferParts:
|
||||
semester.transferPartsFrom(oldSemester)
|
||||
|
||||
for experiment in db.session.scalars(select(Experiment).where(Experiment.active is True)):
|
||||
for experiment in db.session.scalars(select(Experiment).where(Experiment.active == True)):
|
||||
newSemesterExperiment = SemesterExperiment(experiment=experiment, semester=semester)
|
||||
|
||||
if transferAssistants:
|
||||
|
@ -575,7 +575,7 @@ class Semester(db.Model):
|
|||
.join(GroupExperiment)
|
||||
.join(SemesterExperiment)
|
||||
.where(SemesterExperiment.semester == self)
|
||||
.where(ExperimentMark.final_experiment_mark is None)
|
||||
.where(ExperimentMark.final_experiment_mark == None)
|
||||
)
|
||||
|
||||
def set_done(self, next_semester=None):
|
||||
|
|
|
@ -13,7 +13,7 @@ def _reset_admin_password(manage):
|
|||
app = create_app(create_for_server=False)
|
||||
|
||||
with app.app_context(), db.session.begin():
|
||||
admins = db.session.scalars(select(Admin).join(User).where(User.active is True)).all()
|
||||
admins = db.session.scalars(select(Admin).join(User).where(User.active == True)).all()
|
||||
activate_user = False
|
||||
|
||||
if len(admins) == 0:
|
||||
|
|
|
@ -48,7 +48,9 @@ select = [
|
|||
"RUF",
|
||||
]
|
||||
ignore = [
|
||||
"E5",
|
||||
"E501",
|
||||
"E711",
|
||||
"E712",
|
||||
"S3",
|
||||
"S6",
|
||||
"RET504",
|
||||
|
|
Loading…
Reference in a new issue