From: olivier <> Date: Fri, 22 Jan 2010 18:58:12 +0000 (+0000) Subject: allow unpublished item codes to contain either 2 or 3 digits in the 3rd numeric group... X-Git-Tag: 1.1~589 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=4fd864ef99777c671a885d2e2dcc36ff8a6ab437;p=telemeta.git allow unpublished item codes to contain either 2 or 3 digits in the 3rd numeric group ; consolidate codes regex's --- diff --git a/telemeta/models/crem.py b/telemeta/models/crem.py index caeff312..eafac6d1 100755 --- a/telemeta/models/crem.py +++ b/telemeta/models/crem.py @@ -239,7 +239,7 @@ class MediaCollection(MediaResource): def is_valid_code(self, code): "Check if the collection code is well formed" if self.is_published: - regex = '^CNRSMH_E_[0-9]{4}_[0-9]{3}_[0-9]{3}$' + regex = '^CNRSMH_E_[0-9]{4}(_[0-9]{3}){2}$' else: regex = '^CNRSMH_I_[0-9]{4}_[0-9]{3}$' @@ -354,9 +354,9 @@ class MediaItem(MediaResource): def is_valid_code(self, code): "Check if the item code is well formed" if self.collection.is_published: - regex = '^' + self.collection.code + '_[0-9]{2}(_[0-9]{2})?$' + regex = '^' + self.collection.code + '(_[0-9]{2}){1,2}$' else: - regex = '^' + self.collection.code + '_[0-9]{3}(_[0-9]{2})?(_[0-9]{2})?$' + regex = '^' + self.collection.code + '_[0-9]{2,3}(_[0-9]{2}){0,2}$' if re.match(regex, self.code): return True