def save(self, *args, **kwargs): conflict = False if self.start_hour==1 else not self.check_conflict() if self.id is not None and self.start_hour < self.end_hour: super(Lab, self).save(*args, **kwargs) else: #Initial save() if conflict: raise ValidationError(u"Η αίθουσα δεν είναι διαθέσιμη") elif self.start_hour >= self.end_hour: raise ValidationError(u"H ώρα έναρξης του εργαστηρίου είναι μεγαλύτερη της ώρας λήξης") super(Lab, self).save(*args, **kwargs) if not self.hash_id: self.hash_id = get_hashed_id(self.id) super(Lab, self).save(*args, **kwargs)
def save(self, *args, **kwargs): self.check_valid_school() available = self.check_availability() if self.id is not None: if not available: #In case you try to change registered lab from django admin raise ValidationError(u"Κάποιοι σπουδαστές έχουν δηλώσει άλλα εργαστήρια αυτές τις ώρες") if self.absences < 0: self.absences = 0 super(Subscription, self).save(*args, **kwargs) else: #Initial save() if not available: raise ValidationError(u"Έχετε δηλώσει άλλο εργαστήριο αυτές τις ώρες, δοκιμάστε άλλη ώρα ή επιλέξτε άλλον καθηγητή") super(Subscription, self).save(*args, **kwargs) if not self.hash_id: self.hash_id = get_hashed_id(self.id) self.course = self.lab.course super(Subscription, self).save(*args, **kwargs)
def save(self, *args, **kwargs): super(Course, self).save(*args, **kwargs) if not self.hash_id: self.hash_id = get_hashed_id(self.id) super(Course, self).save(*args, **kwargs)
def save(self, *args, **kwargs): self.is_school = True super(School, self).save(*args, **kwargs) if not self.hash_id: self.hash_id = get_hashed_id(self.user.id) super(School, self).save(*args, **kwargs)
def save(self, *args, **kwargs): super(Student, self).save(*args, **kwargs) if not self.hash_id: self.hash_id = get_hashed_id(self.user.id) super(Student, self).save(*args, **kwargs)
def save(self, *args, **kwargs): self.is_teacher = True super(Teacher, self).save(*args, **kwargs) if not self.hash_id: self.hash_id = get_hashed_id(self.user.id) super(Teacher, self).save(*args, **kwargs)