diff --git a/advlabdb/models.py b/advlabdb/models.py index 36cd3bf..b74e73d 100644 --- a/advlabdb/models.py +++ b/advlabdb/models.py @@ -414,11 +414,14 @@ class Semester(db.Model): __table_args__ = (db.UniqueConstraint(label, year),) - def customInit(label, year, oldSemester, transferParts, transferAssistants): + def customInit(label, year): if label not in ("WS", "SS"): raise DataBaseException("The semester label has to be WS or SS!") - semester = Semester(label=label, year=year) + return Semester(label, year) + + def customInit(label, year, oldSemester, transferParts, transferAssistants): + semester = Semester.customInit(label=label, year=year) if transferParts: semester.transferPartsFrom(oldSemester) diff --git a/testDB.py b/testDB.py index 5a61ed7..9eda92c 100644 --- a/testDB.py +++ b/testDB.py @@ -17,8 +17,8 @@ with app.app_context(): db.session.add(program2) db.session.add(program3) - sem1 = Semester(label="SS", year=22) - sem2 = Semester(label="WS", year=22) + sem1 = Semester.customInit(label="SS", year=22) + sem2 = Semester.customInit(label="WS", year=22) db.session.add(sem1) db.session.add(sem2)