1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-09-17 18:31:15 +00:00
This commit is contained in:
Mo 2023-11-02 20:04:09 +01:00
parent a33a7ec060
commit e2d5a920ec
7 changed files with 37 additions and 20 deletions

View file

@ -25,7 +25,7 @@ def backup(backup_prefix):
now = datetime.now().strftime("%d_%m_%Y_%H_%M_%S")
dest = db_bk_dir / f"{backup_prefix}_{now}.sqlite"
status = subprocess.run(["sqlite3", db_path, f".backup {dest}"]).returncode
status = subprocess.run(["sqlite3", db_path, f".backup {dest}"], check=False).returncode
if status == 0:
flash(f"Created a database backup at the path {dest}", "success")
else:

View file

@ -311,8 +311,7 @@ class UserView(SecureAdminModelView):
f"{model.email} registered with role(s): {', '.join(role.name for role in model.roles)}.",
category="success",
)
else:
if model == current_user:
elif model == current_user:
flash(f"Active semester is {model.active_semester}.", "warning")
@ -418,8 +417,7 @@ class SemesterView(SecureAdminModelView):
else:
current_user.active_semester = model
flash(f"Active semester changed to the new semester {model}!", "warning")
else:
if model.done:
elif model.done:
next_semester = db.session.get(Semester, model.id + 1)
model.set_done(next_semester)

View file

@ -25,7 +25,7 @@ from .models import (
def is_null(entry):
return entry == "NULL" or entry == ""
return entry in {"NULL", ""}
def nullable(entry):

View file

@ -457,8 +457,7 @@ class Appointment(db.Model):
if assistant is not None:
if assistant not in semesterExperimentAssistants:
raise DatabaseException(f"{assistant} is not responsible for {semesterExperiment}!")
else:
if len(semesterExperimentAssistants) == 1:
elif len(semesterExperimentAssistants) == 1:
assistant = semesterExperimentAssistants[0]
else:
raise DatabaseException(

View file

@ -1,6 +1,6 @@
from datetime import date
from math import ceil
from random import randint, random
from random import randint
import click
from flask_security.utils import hash_password
@ -97,7 +97,7 @@ def _generate_test_db():
part = ss_parts[ind % len(ss_parts)]
add_part_student(student, part)
if random() < 0.9: # nosec: B311
if ind % 10 < 9:
# Transfer to the next part in the second semester
if part == bs_1_ss_part:
add_part_student(student, bs_2_ws_part)

View file

@ -13,7 +13,7 @@ from cli.test.generate_test_db.main import _generate_test_db
class Manage:
@staticmethod
def run(command: str, **kwargs):
return subprocess.run(command, shell=True, **kwargs) # nosec B602
return subprocess.run(command, shell=True, check=False, **kwargs) # nosec B602
@staticmethod
def box(message: str):

View file

@ -27,8 +27,28 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.ruff]
select = ["E", "W", "F", "I", "UP", "YTT", "S", "B", "C4", "ICN", "PIE", "Q", "RET", "SIM", "TID", "PTH"]
ignore = ["E5", "S3", "S6", "RET504"]
select = [
"E",
"W",
"F",
"I",
"UP",
"YTT",
"S",
"B",
"C4",
"ICN",
"PIE",
"Q",
"RET",
"SIM",
"TID",
"PTH",
"ERA",
"PL",
"NPY",
]
ignore = ["E5", "S3", "S6", "RET504", "PLR0912", "PLR0915", "PLW2901", "PLR2004"]
line-length = 120
[tool.ruff.per-file-ignores]