From: Thomas Fillon Date: Thu, 24 Aug 2017 08:53:29 +0000 (+0200) Subject: Move resource code validators outside the MediaBaseResource class X-Git-Tag: 1.6.4^2~4^2~3 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f99d5e3280fdc5af0839999b2520379545274ada;p=telemeta.git Move resource code validators outside the MediaBaseResource class Conflicts: telemeta/models/resource.py --- diff --git a/telemeta/models/resource.py b/telemeta/models/resource.py index 195b7848..717d946c 100644 --- a/telemeta/models/resource.py +++ b/telemeta/models/resource.py @@ -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'))