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