1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-04 22:40:30 +00:00

Apply RET

This commit is contained in:
Mo 2023-11-02 19:24:14 +01:00
parent d408e8fc08
commit 029cc974e3
5 changed files with 17 additions and 15 deletions

View file

@ -323,16 +323,16 @@ class SemesterView(SecureAdminModelView):
last_semester = Semester.lastSemester()
if last_semester.label == "WS":
return "SS"
else:
return "WS"
return "WS"
@staticmethod
def defaultFormYear():
last_semester = Semester.lastSemester()
if last_semester.label == "WS":
return last_semester.year + 1
else:
return last_semester.year
return last_semester.year
label = RadioField(
"Semester",
@ -857,8 +857,8 @@ def userHasRoleFilterFactory(column, role_name):
query = query.join(User)
if bool(int(value)): # value is string "0" or "1"
return query.join(User.roles).where(Role.name == role_name)
else:
return query.where(not_(User.roles.any(Role.name == role_name)))
return query.where(not_(User.roles.any(Role.name == role_name)))
return UserHasRoleFilter(column, f"Currently has {role_name} role")
@ -1392,7 +1392,8 @@ class AnalysisView(SecureAdminBaseView):
if form.validate_on_submit():
if form.assistant_marks_submit.data:
return assistant_marks_analysis(self)
elif form.final_part_marks_submit.data:
if form.final_part_marks_submit.data:
return final_part_marks_analysis(self)
return self.render("analysis/analysis.jinja.html", form=form)

View file

@ -34,16 +34,14 @@ def load_config(file_name: str, data_dir: Path):
def get_secrets(data_dir: Path):
config = load_config("secrets.ini", data_dir)
secrets = config["Secrets"]
return secrets
return config["Secrets"]
def get_settings(data_dir: Path):
config = load_config("settings.ini", data_dir)
settings = config["Settings"]
return settings
return config["Settings"]
def set_config(app, data_dir: Path):

View file

@ -280,6 +280,8 @@ class SecureAssistantModelView(CustomModelView):
self.handle_view_exception(ModelViewException("Unauthorized action!"))
return redirect(self.url)
return None
def on_model_delete(self, model):
reportBadAttempt("An assistant tried to delete a model!")
raise ModelViewException("Assistants can not delete models!")

View file

@ -657,9 +657,9 @@ class ExperimentMark(db.Model):
def check(part_student, group_experiment):
if not part_student.group:
raise DatabaseException("The part student does not have a group yet!")
else:
if group_experiment not in part_student.group.group_experiments:
raise DatabaseException("The group of the part student does not have the given group experiment!")
if group_experiment not in part_student.group.group_experiments:
raise DatabaseException("The group of the part student does not have the given group experiment!")
def __init__(self, part_student, group_experiment, **kwargs):
ExperimentMark.check(part_student, group_experiment)

View file

@ -27,7 +27,8 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.ruff]
select = ["E1", "E4", "E7", "E9", "W", "F", "I", "UP", "YTT", "S1", "S5", "S7", "B", "C4"]
select = ["E", "W", "F", "I", "UP", "YTT", "S", "B", "C4", "ICN", "PIE", "Q", "RET"]
ignore = ["E5", "S3", "S6", "RET504"]
line-length = 120
[tool.ruff.per-file-ignores]