diff --git a/advlabdb/models.py b/advlabdb/models.py index c45966b..445ebba 100644 --- a/advlabdb/models.py +++ b/advlabdb/models.py @@ -378,7 +378,9 @@ class Admin(db.Model): class Appointment(db.Model): id = db.Column(db.Integer, primary_key=True) - date = db.Column(db.Date, nullable=False) # To be specified with the python package "datetime" + date = db.Column( + db.Date, db.CheckConstraint(f"date BETWEEN '20{MIN_YEAR}-01-01' AND '20{MAX_YEAR}-01-01'"), nullable=False + ) # To be specified with the python package "datetime" special = db.Column(db.Boolean, default=False, nullable=False) # In the break or not group_experiment_id = db.Column(db.Integer, db.ForeignKey("group_experiment.id"), nullable=False) diff --git a/advlabdb/scripts/test/test_database.py b/advlabdb/scripts/test/test_database.py index f5eb754..9eccc5f 100644 --- a/advlabdb/scripts/test/test_database.py +++ b/advlabdb/scripts/test/test_database.py @@ -142,8 +142,8 @@ def main(): db.session.add(as1) db.session.add(as2) - ap1 = Appointment(date=date(2021, 3, 21), special=True, group_experiment=gx1, assistant=as1) - ap2 = Appointment(date=date(2021, 3, 22), special=True, group_experiment=gx2, assistant=as2) + ap1 = Appointment(date=date(2022, 3, 21), special=True, group_experiment=gx1, assistant=as1) + ap2 = Appointment(date=date(2022, 3, 22), special=True, group_experiment=gx2, assistant=as2) db.session.add(ap1) db.session.add(ap2) diff --git a/docs/database_import/database_import.adoc b/docs/database_import/database_import.adoc index 640594d..43f75ef 100644 --- a/docs/database_import/database_import.adoc +++ b/docs/database_import/database_import.adoc @@ -71,7 +71,7 @@ The type of the attributes can be seen in the drawio file link:DB.drawio[] which * group_id === Appointment -* date -> 21.08.2021 +* date -> 21.08.2022 * special -> 1 / 0 * group_experiment_id * assistant_email