2mG5P3PKomMTPV5stPAlLo changeset

Changeset623164383039 (b)
ParentNone (a)
ab
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)
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--- 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)