diff --git a/advlabdb/models.py b/advlabdb/models.py index 47d725c..37a6865 100644 --- a/advlabdb/models.py +++ b/advlabdb/models.py @@ -60,6 +60,12 @@ class Student(db.Model): part_students = db.relationship("PartStudent", back_populates="student", lazy=True) + def __init__(self, uni_email, contact_email=None, **kwargs): + if contact_email is not None and uni_email.strip() == contact_email.strip(): + contact_email = None + + super().__init__(uni_email=uni_email, contact_email=contact_email, **kwargs) + def str(self): return f"{self.first_name} {self.last_name}"