]> git.parisson.com Git - telemeta.git/commitdiff
Move resource code validators outside the MediaBaseResource class
authorThomas Fillon <thomas@parisson.com>
Thu, 24 Aug 2017 08:53:29 +0000 (10:53 +0200)
committerThomas Fillon <thomas@parisson.com>
Thu, 24 Aug 2017 08:58:53 +0000 (10:58 +0200)
Conflicts:
telemeta/models/resource.py

telemeta/models/resource.py

index 195b78480b34af5cd69b1dc3104ac0efd43a272d..717d946ca05d508f0354dad63103beacb2544366 100644 (file)
@@ -56,16 +56,16 @@ class MediaResource(ModelCore):
     class Meta:
         abstract = True
 
+def is_valid_resource_code(value):
+    "Check if the resource code is well formed"
+    regex = '^' + resource_code_regex + '$'
+    if not re.match(regex, value):
+        raise ValidationError(u'%s is not a valid resource code' % value)
+
 
 class MediaBaseResource(MediaResource):
     "Describe a media base resource"
 
-    def is_valid_resource_code(value):
-        "Check if the resource code is well formed"
-        regex = '^' + resource_code_regex + '$'
-        if not re.match(regex, value):
-            raise ValidationError(u'%s is not a valid resource code' % value)
-
     title                 = CharField(_('title'), required=True)
     description           = CharField(_('description_old'))
     descriptions          = TextField(_('description'))