From: olivier <> Date: Fri, 18 May 2007 10:28:50 +0000 (+0000) Subject: - the media objects ID regex is now in the models, following DRY (see urls) X-Git-Tag: 1.1~936 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=3815c512493ac017e7c62e8aa0ce1ab5e01f73e3;p=telemeta.git - the media objects ID regex is now in the models, following DRY (see urls) - media objects IDs are now validated at model level - experimenting new logo by Julia - trying some new layout + cleaned css - renamed "dictionaries" to "enumerations" - new PublishingStatus enumerations model (you simply need to syncdb) --- diff --git a/telemeta/htdocs/css/telemeta.css b/telemeta/htdocs/css/telemeta.css index 08aaed8b..b21658f7 100644 --- a/telemeta/htdocs/css/telemeta.css +++ b/telemeta/htdocs/css/telemeta.css @@ -1,7 +1,4 @@ -body { - font-family: Verdana; - font-size: 80%; -} +body { font-family: Verdana; font-size: 80%; } a:link, a:visited { border-bottom:1px dotted #BBBBBB; @@ -9,51 +6,35 @@ a:link, a:visited { text-decoration:none; } -a:link:hover, a:visited:hover { - background-color:#EEEEEE; - color:#555555; -} +a:link:hover, a:visited:hover { background-color:#EEEEEE; color:#555555; } +a img { border: none; } #header { - border-bottom: solid 1px black; padding-bottom: 0.2em; padding-top: 0.2em; } -#header a { - text-decoration: none; -} -#header a img { - border: none; -} - - -#menu { - text-align: right; - clear: right; -} -#submenu { - clear: right; - float: right; - padding-top: 1em; -} -#submenu a { - color: #000066; -} +#logo { padding-top: 1ex; } +#logo a, #logo a:hover { border: none; background: transparent; } -#quick_search { - position: absolute; - top: 2em; - right: 1em; +#menu a, #menu a:hover { border: none;} +#menu { + text-align: right; + clear: right; + background: #DDDDDD; + padding: 1px; + border-bottom: solid 1px black; } +#submenu { clear: right; float: right; padding-top: 1em; } +#submenu a { color: #000066; } +#quick_search { position: absolute; top: 2em; right: 1em; } #quick_search input { vertical-align: middle; font-size: 90%; } -#quick_search_pattern { -} +#quick_search_pattern { } .item_visualization { clear: right; @@ -61,14 +42,8 @@ a:link:hover, a:visited:hover { padding: 1ex; margin-top: 1em; } -.item_visualization select { - width: 200px; -} - -.item_visualization img { - width: 300px; - border: solid 1px black; -} +.item_visualization select { width: 200px; } +.item_visualization img { width: 300px; border: solid 1px black; } /* Styles for tabular listings (stolen from trac) */ @@ -163,6 +138,4 @@ label.disabled { color: #d7d7d7 } /* HTML dublin core display */ -table.dublincore { - width: auto; -} +table.dublincore { width: auto; } diff --git a/telemeta/htdocs/images/logo.png b/telemeta/htdocs/images/logo.png index 0041d069..b99eb355 100644 Binary files a/telemeta/htdocs/images/logo.png and b/telemeta/htdocs/images/logo.png differ diff --git a/telemeta/models.py b/telemeta/models.py index 067dc2ce..f2d47579 100644 --- a/telemeta/models.py +++ b/telemeta/models.py @@ -7,13 +7,18 @@ # # Author: Olivier Guilyardi -import telemeta from django.db import models from django.db.models import Q -from telemeta.core import * from django.core.exceptions import ObjectDoesNotExist +from django.core import validators + +import telemeta +from telemeta.core import * from telemeta import dublincore as dc +# Regular (sub) expression for matching/validating media objects IDs +media_id_regex = r'[0-9A-Za-z._:%?-]+' + class MediaModel(Component): pass @@ -25,27 +30,22 @@ class MediaCore: fields_dict[field.name] = getattr(self, field.name) return fields_dict -# def dc_elements(self): -# """Return model fields mapped to Dublin Core elements, as a dict of -# the form: {dc_element_name: [value1, value2, ....], ...} -# """ -# fields_dict = {} -# for field in self._meta.fields: -# if (hasattr(field, 'dc_element')): -# if fields_dict.has_key(field.dc_element): -# fields_dict[field.dc_element].append(getattr(self, field.name)) -# else: -# fields_dict[field.dc_element] = [getattr(self, field.name)] -# -# return fields_dict - class PhysicalFormat(models.Model): value = models.CharField(maxlength=250) - is_dictionary = True + is_enumeration = True + def __str__(self): + return self.value + class Meta: + ordering = ['value'] + +class PublishingStatus(models.Model): + value = models.CharField(maxlength=250) + is_enumeration = True def __str__(self): return self.value class Meta: ordering = ['value'] + verbose_name_plural = "Publishing status" class MediaCollectionManager(models.Manager): def quick_search(self, pattern): @@ -55,20 +55,22 @@ class MediaCollectionManager(models.Manager): Q(creator__icontains=pattern) ) - class MediaCollection(models.Model, MediaCore): "Group related media items" + id_regex = media_id_regex + id_validator = validators.MatchesRegularExpression('^' + id_regex + '$') + publisher_reference = models.CharField(maxlength=250, blank=True) physical_format = models.CharField(maxlength=250, blank=True) id = models.CharField(maxlength=250, primary_key=True, - verbose_name='identifier') + verbose_name='identifier', validator_list=[id_validator]) title = models.CharField(maxlength=250) native_title = models.CharField(maxlength=250, blank=True) physical_items_num = models.CharField(maxlength=250, blank=True) publishing_status = models.CharField(maxlength=250, blank=True) - is_original = models.CharField(maxlength=250) - is_full_copy = models.CharField(maxlength=250) + is_original = models.CharField(maxlength=250, blank=True) + is_full_copy = models.CharField(maxlength=250, blank=True) copied_from = models.ForeignKey('self', null=True, blank=True) creator = models.CharField(maxlength=250) booklet_writer = models.CharField(maxlength=250, blank=True) @@ -146,12 +148,15 @@ class MediaItemManager(models.Manager): class MediaItem(models.Model, MediaCore): "Describe a item with metadata" + id_regex = media_id_regex + id_validator = validators.MatchesRegularExpression('^' + id_regex + '$') + ref = models.CharField(maxlength=250, blank=True) format = models.CharField(maxlength=250, blank=True) collection = models.ForeignKey(MediaCollection, related_name="items") face_plage = models.CharField(maxlength=250, blank=True) id = models.CharField(maxlength=250, primary_key=True, - verbose_name='identifier') + verbose_name='identifier', validator_list=[id_validator]) duree = models.CharField(maxlength=250, blank=True) dates_enregistr = models.CharField(maxlength=250, blank=True) etat = models.CharField(maxlength=250, blank=True) diff --git a/telemeta/templates/admin.html b/telemeta/templates/admin.html index 8de5c33a..171f5a31 100644 --- a/telemeta/templates/admin.html +++ b/telemeta/templates/admin.html @@ -10,14 +10,15 @@