Revision 623164383039 () - Diff

Link to this snippet: https://friendpaste.com/2mG5P3PKomMTPV5stPAlLo
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)