]> git.parisson.com Git - telemeta.git/commitdiff
Exclude IpAuth FTM, use some native charfield, fix collection validation function
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 20 Jan 2017 15:12:59 +0000 (16:12 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 20 Jan 2017 15:12:59 +0000 (16:12 +0100)
app/settings.py
telemeta/models/collection.py
telemeta/models/corpus.py
telemeta/models/fields.py
telemeta/models/fonds.py
telemeta/models/resource.py

index 5115889b28f903e6e8a3f23f5a97d8c55560919a..a56fd02b7c2a523b30778e37a466ff9d80a1cc0f 100644 (file)
@@ -159,7 +159,7 @@ INSTALLED_APPS = (
     'sorl.thumbnail',
     'timezones',
     'jqchat',
-    'ipauth',
+    'ipauth',
     'extra_views',
     'debug_toolbar',
     'bootstrap3',
index 419d765ca703fe830e980ffb5e741d07beaef14c..60a6eb55510898b6f8083ebdaa808b5fb450832e 100644 (file)
@@ -40,17 +40,19 @@ collection_unpublished_code_regex = getattr(settings, 'COLLECTION_UNPUBLISHED_CO
 collection_code_regex = '(?:%s|%s)' % (collection_published_code_regex,
                                        collection_unpublished_code_regex)
 
+
+def is_valid_collection_code(value):
+    "Check if the collection code is well formed"
+    regex = '^' + collection_code_regex + '$'
+    if not re.match(regex, value):
+        raise ValidationError(u'%s is not a valid collection code' % value)
+
+
 class MediaCollection(MediaResource):
     "Describe a collection of items"
 
     element_type = 'collection'
 
-    def is_valid_collection_code(value):
-        "Check if the collection code is well formed"
-        regex = '^' + collection_code_regex + '$'
-        if not re.match(regex, value):
-            raise ValidationError(u'%s is not a valid collection code' % value)
-
     # General informations
     title                 = CharField(_('title'), required=True)
     alt_title             = CharField(_('original title / translation'))
index ffd0ea20683dcc27dccc5a8c24312d57f1c923ab..f7a06b56731b7631004890c669e743e2b30e795a 100644 (file)
@@ -36,6 +36,7 @@ class MediaCorpus(MediaBaseResource):
 
     children = models.ManyToManyField(MediaCollection, related_name="corpus",
                                       verbose_name=_('collections'),  blank=True)
+                                      
     recorded_from_year    = IntegerField(_('recording year (from)'), help_text=_('YYYY'))
     recorded_to_year      = IntegerField(_('recording year (until)'), help_text=_('YYYY'))
 
index 3616ca88ffa8f018df619ee37167c37e1791fec9..8629d0432b0864a6f0a5820cdca40fa385fd6c34 100644 (file)
@@ -228,12 +228,6 @@ class CharField(models.CharField):
             kwargs['max_length'] = 250
         super(CharField, self).__init__(*args, **normalize_field(kwargs, ''))
 
-    def deconstruct(self):
-        name, path, args, kwargs = super(CharField, self).deconstruct()
-        print kwargs
-        del kwargs["max_length"]
-        return name, path, args, kwargs
-
 
 class IntegerField(models.IntegerField):
     """IntegerField normalized with normalize_field()"""
index e5b8dc13ce34197cb65be55a99ab871076b2205f..a46dcef05399a1041ed1edb3a7fe1297bc705888 100644 (file)
@@ -26,6 +26,7 @@ from django.utils.translation import ugettext_lazy as _
 from telemeta.models.core import *
 from telemeta.models.resource import *
 from telemeta.models.corpus import *
+from django.db import models
 
 
 class MediaFonds(MediaBaseResource):
index 54c1031ec48b59c386f63a6646da4c3534098a3c..9fe346f3ae467973d0cb187c6e04c0482e960000 100644 (file)
@@ -58,11 +58,11 @@ class MediaResource(ModelCore):
 class MediaBaseResource(MediaResource):
     "Describe a media base resource"
 
-    title                 = CharField(_('title'), required=True)
-    description           = CharField(_('description_old'))
-    descriptions          = TextField(_('description'))
-    code                  = CharField(_('code'), unique=True, required=True)
-    public_access         = CharField(_('public access'), choices=PUBLIC_ACCESS_CHOICES, max_length=16, default="metadata")
+    title                 = models.CharField(_('title'), max_length=250)
+    description           = models.CharField(_('description_old'), max_length=250, blank=True, null=True)
+    descriptions          = models.TextField(_('description'), blank=True)
+    code                  = models.CharField(_('code'), unique=True, max_length=250)
+    public_access         = models.CharField(_('public access'), choices=PUBLIC_ACCESS_CHOICES, max_length=16, default="metadata")
 
     def __unicode__(self):
         return self.code