--- Revision None +++ Revision 623164383039 @@ -0,0 +1,17 @@ + def clean(self): + + if self.operation_id and self.operation.slug_libelle == 'location': + if not self.periode: + raise ValidationError("Pour une location, le champ 'periode' est obligatoire") + + if self.p_image and self.p_image.size() > IMAGE_SIZE: + raise ValidationError("La taille maximale est de %s"%filesizeformat(IMAGE_SIZE)) + + if self.open_date and self.close_date: + if self.open_date > self.close_date: + raise ValidationError("Mauvaise configuration des dates") + + if ANNONCES_LIFETIMES: + date_ecart = self.close_date - self.open_date + if date_ecart.days > ANNONCES_LIFETIMES: + raise ValidationError(u"La durée d'une annonce ne peut pas dépasser %s jour(s)"%ANNONCES_LIFETIMES)