]> git.parisson.com Git - telemeta.git/commitdiff
model: fix unpublished item code validation
authorolivier <>
Wed, 20 Jan 2010 15:45:18 +0000 (15:45 +0000)
committerolivier <>
Wed, 20 Jan 2010 15:45:18 +0000 (15:45 +0000)
telemeta/models/crem.py

index eb6852f5595a7fc91fe239a5ae53c31ddd92a0da..4dc5141c311c51bb80607e1c428ef5cf3e68b291 100755 (executable)
@@ -287,7 +287,11 @@ class MediaItem(MediaResource):
 
     def is_valid_code(self, code):
         "Check if the item code is well formed"
-        regex = '^' + self.collection.code + '_[0-9]{2}(_[0-9]{2})?$'
+        if self.collection.is_published:
+            regex = '^' + self.collection.code + '_[0-9]{2}(_[0-9]{2})?$'
+        else:
+            regex = '^' + self.collection.code + '_[0-9]{3}(_[0-9]{2})?(_[0-9]{2})?$'
+
         if re.match(regex, self.code):
             return True