1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-09-19 18:31:16 +00:00

Save contact_email only if it is different

This commit is contained in:
Mo 2022-09-08 00:51:34 +02:00
parent fe98376efb
commit 5704633d14

View file

@ -60,6 +60,12 @@ class Student(db.Model):
part_students = db.relationship("PartStudent", back_populates="student", lazy=True) 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): def str(self):
return f"{self.first_name} {self.last_name}" return f"{self.first_name} {self.last_name}"