From 00ee49fcf2e7efa84c074df77a057e884552383f Mon Sep 17 00:00:00 2001 From: olivier <> Date: Wed, 27 Jan 2010 13:21:03 +0000 Subject: [PATCH] add internationalized verbose names to model fields, and gettext french translation ; update collection detail template --- telemeta/locale/fr/LC_MESSAGES/django.mo | Bin 0 -> 5220 bytes telemeta/locale/fr/LC_MESSAGES/django.po | 418 ++++++++++++++++++ telemeta/models/core.py | 2 +- telemeta/models/crem.py | 291 ++++++------ telemeta/models/dublincore.py | 10 +- telemeta/templates/telemeta_default/base.html | 5 - .../telemeta_default/collection_detail.html | 136 +++--- telemeta/templatetags/telemeta_utils.py | 60 +++ 8 files changed, 705 insertions(+), 217 deletions(-) create mode 100644 telemeta/locale/fr/LC_MESSAGES/django.mo create mode 100644 telemeta/locale/fr/LC_MESSAGES/django.po diff --git a/telemeta/locale/fr/LC_MESSAGES/django.mo b/telemeta/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..ac40e2e0a2178aa5fa7af21fe72c559d9b4bd328 GIT binary patch literal 5220 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 literal 0 HcmV?d00001 diff --git a/telemeta/locale/fr/LC_MESSAGES/django.po b/telemeta/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 00000000..2a6d04ac --- /dev/null +++ b/telemeta/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,418 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-01-27 14:13+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: models/core.py:127 +msgid "Duration" +msgstr "" + +#: models/core.py:132 +msgid "Enter a valid duration in HH:MM[:ss[.uuuuuu]] format." +msgstr "" + +#: models/crem.py:150 +msgid "reference" +msgstr "référence" + +#: models/crem.py:152 +msgid "archive format" +msgstr "format d'archivage" + +#: models/crem.py:153 models/crem.py:289 +msgid "old code" +msgstr "ancienne cote" + +#: models/crem.py:154 models/crem.py:290 +msgid "code" +msgstr "cote" + +#: models/crem.py:155 models/crem.py:299 models/crem.py:379 +msgid "title" +msgstr "titre" + +#: models/crem.py:156 models/crem.py:300 +msgid "original title / translation" +msgstr "titre original / traduction" + +#: models/crem.py:157 +msgid "number of components (medium / piece)" +msgstr "nb de composants (support / pièce)" + +#: models/crem.py:159 +msgid "secondary edition" +msgstr "réédition" + +#: models/crem.py:160 +msgid "depositor / contributor" +msgstr "déposant / contributeur" + +#: models/crem.py:161 +msgid "author of published notice" +msgstr "auteur de la notice éditée" + +#: models/crem.py:162 +msgid "related documentation" +msgstr "documentation associée" + +#: models/crem.py:163 models/crem.py:308 +msgid "collector" +msgstr "collecteur" + +#: models/crem.py:164 +msgid "collector identical to depositor" +msgstr "collecteur identique au déposant" + +#: models/crem.py:166 +msgid "publisher / status" +msgstr "éditeur / statut" + +#: models/crem.py:167 +msgid "published" +msgstr "édité" + +#: models/crem.py:168 +msgid "year published" +msgstr "année de parution" + +#: models/crem.py:170 +msgid "publisher collection" +msgstr "collection éditeur" + +#: models/crem.py:171 +msgid "publisher serial number" +msgstr "numéro dans la série" + +#: models/crem.py:172 +msgid "bibliographic references" +msgstr "références bibliographiques" + +#: models/crem.py:174 +msgid "mode of acquisition" +msgstr "mode d'acquisition" + +#: models/crem.py:175 models/crem.py:314 +msgid "comment" +msgstr "commentaire" + +#: models/crem.py:177 +msgid "record author" +msgstr "rédacteur fiche" + +#: models/crem.py:179 +msgid "record writer" +msgstr "saisie fiche" + +#: models/crem.py:181 +msgid "legal rights" +msgstr "droit d'utilisation" + +#: models/crem.py:182 +msgid "copies" +msgstr "autres exemplaires" + +#: models/crem.py:183 +msgid "recording year (from)" +msgstr "année d'enregistrement (depuis)" + +#: models/crem.py:184 +msgid "recording year (until)" +msgstr "année d'enregistrement (jusqu'à)" + +#: models/crem.py:186 +msgid "recording context" +msgstr "context d'enregistrement" + +#: models/crem.py:187 models/crem.py:291 +msgid "approximative duration" +msgstr "durée approximative" + +#: models/crem.py:188 +msgid "document type" +msgstr "type de document" + +#: models/crem.py:189 +msgid "archiver notes" +msgstr "notes de l'archiviste" + +#: models/crem.py:190 +msgid "status" +msgstr "etat" + +#: models/crem.py:191 +msgid "CNRS depositor" +msgstr "déposant CNRS" + +#: models/crem.py:192 +msgid "items finished" +msgstr "fiches faîtes" + +#: models/crem.py:193 +msgid "a_informer_07_03" +msgstr "" + +#: models/crem.py:195 +msgid "A/D conversion" +msgstr "numérisation" + +#: models/crem.py:196 models/crem.py:316 +msgid "public access" +msgstr "accès public" + +#: models/crem.py:232 +msgid "states / nations" +msgstr "états / nations" + +#: models/crem.py:245 +msgid "populations / social groups" +msgstr "populations / groupes sociaux" + +#: models/crem.py:253 models/crem.py:368 +msgid "computed duration" +msgstr "durée calculée" + +#: models/crem.py:287 +msgid "collection" +msgstr "" + +#: models/crem.py:288 +msgid "item number" +msgstr "n° de l'item" + +#: models/crem.py:292 +msgid "recording date (from)" +msgstr "date d'enregistrement (depuis)" + +#: models/crem.py:293 +msgid "recording date (until)" +msgstr "date d'enregistrement (jusqu'à)" + +#: models/crem.py:295 models/crem.py:614 models/crem.py:628 +msgid "location" +msgstr "lieu" + +#: models/crem.py:296 +msgid "location comment" +msgstr "commentaire lieu" + +#: models/crem.py:298 models/crem.py:710 +msgid "population / social group" +msgstr "population / groupe social" + +#: models/crem.py:301 +msgid "author" +msgstr "auteur" + +#: models/crem.py:303 +msgid "vernacular name" +msgstr "nom vernaculaire" + +#: models/crem.py:304 +msgid "comments" +msgstr "commentaires" + +#: models/crem.py:305 +msgid "published reference" +msgstr "référence éditée" + +#: models/crem.py:306 +msgid "moda_execut" +msgstr "" + +#: models/crem.py:307 +msgid "copy of" +msgstr "copie de" + +#: models/crem.py:309 +msgid "cultural area" +msgstr "aire culturelle" + +#: models/crem.py:311 +msgid "generic name" +msgstr "nom générique" + +#: models/crem.py:312 +msgid "collector selection" +msgstr "sélection collecteur" + +#: models/crem.py:313 +msgid "depositor reference" +msgstr "référence du déposant" + +#: models/crem.py:315 +msgid "file" +msgstr "fichier" + +#: models/crem.py:378 models/crem.py:504 models/crem.py:644 +msgid "item" +msgstr "item" + +#: models/crem.py:380 +msgid "start" +msgstr "début" + +#: models/crem.py:381 +msgid "end" +msgstr "fin" + +#: models/crem.py:391 models/crem.py:660 +msgid "value" +msgstr "valeur" + +#: models/crem.py:461 models/crem.py:471 models/crem.py:535 models/crem.py:558 +#: models/crem.py:606 models/crem.py:700 models/crem.py:711 +msgid "name" +msgstr "nom" + +#: models/crem.py:482 models/crem.py:495 models/crem.py:506 +msgid "instrument" +msgstr "" + +#: models/crem.py:484 +msgid "parent instrument" +msgstr "instrument parent" + +#: models/crem.py:493 models/crem.py:508 models/crem.py:615 +msgid "alias" +msgstr "alias" + +#: models/crem.py:509 +msgid "instruments num" +msgstr "nb instruments" + +#: models/crem.py:510 +msgid "interprets" +msgstr "interprètes" + +#: models/crem.py:519 +msgid "username" +msgstr "nom d'utilisateur" + +#: models/crem.py:520 +msgid "level" +msgstr "niveau" + +#: models/crem.py:521 +msgid "first name" +msgstr "prénom" + +#: models/crem.py:522 +msgid "last name" +msgstr "nom de famille" + +#: models/crem.py:523 +msgid "phone" +msgstr "téléphone" + +#: models/crem.py:524 +msgid "email" +msgstr "e-mail" + +#: models/crem.py:547 +msgid "playlist" +msgstr "liste de lecture" + +#: models/crem.py:548 +msgid "resource type" +msgstr "type de ressource" + +#: models/crem.py:549 +msgid "resource" +msgstr "ressource" + +#: models/crem.py:559 +msgid "type" +msgstr "" + +#: models/crem.py:560 +msgid "complete type" +msgstr "type complet" + +#: models/crem.py:562 +msgid "current name" +msgstr "nom actuel" + +#: models/crem.py:563 models/crem.py:616 +msgid "authoritative" +msgstr "officiel" + +#: models/crem.py:605 +msgid "identifier" +msgstr "identifiant" + +#: models/crem.py:630 +msgid "parent location" +msgstr "lieu parent" + +#: models/crem.py:645 +msgid "keyword" +msgstr "mot-clé" + +#: models/crem.py:659 +msgid "publisher" +msgstr "éditeur" + +#: models/crem.py:673 +msgid "element type" +msgstr "type d'élément" + +#: models/crem.py:674 +msgid "element identifier" +msgstr "identifiant de l'élément" + +#: models/crem.py:675 +msgid "modification type" +msgstr "type de modification" + +#: models/crem.py:676 +msgid "time" +msgstr "heure" + +#: models/crem.py:677 +msgid "user" +msgstr "utilisateur" + +#: templates/telemeta_default/collection_detail.html:51 +msgid "Recording year" +msgstr "Année d'enregistrement" + +#: templates/telemeta_default/collection_detail.html:61 +msgid "Geographic and cultural informations" +msgstr "Indications géographiques et culturelles" + +#: templates/telemeta_default/collection_detail.html:74 +msgid "Legal mentions" +msgstr "Mentions légales" + +#: templates/telemeta_default/collection_detail.html:94 +msgid "Archiving data" +msgstr "Données d'archivage" + +#: templates/telemeta_default/collection_detail.html:115 +msgid "Technical data" +msgstr "Données techniques" + +#: templates/telemeta_default/collection_detail.html:120 +msgid "Media type" +msgstr "Type de media" + +#: templates/telemeta_default/collection_detail.html:120 +msgid "Audio" +msgstr "" + +#: templates/telemeta_default/collection_detail.html:124 +msgid "Number of items" +msgstr "Nombre d'items" diff --git a/telemeta/models/core.py b/telemeta/models/core.py index 8e9ac64f..c0618c2d 100644 --- a/telemeta/models/core.py +++ b/telemeta/models/core.py @@ -133,7 +133,7 @@ class DurationField(models.Field): } def __init__(self, *args, **kwargs): - super(DurationField, self).__init__(args, **normalize_field(kwargs, '00:00')) + super(DurationField, self).__init__(*args, **normalize_field(kwargs, '00:00')) def get_internal_type(self): return 'TimeField' diff --git a/telemeta/models/crem.py b/telemeta/models/crem.py index e4804531..dd937840 100755 --- a/telemeta/models/crem.py +++ b/telemeta/models/crem.py @@ -38,10 +38,12 @@ import cremquery as query from xml.dom.minidom import getDOMImplementation from telemeta.util.unaccent import unaccent_icmp import re +from django.db.models import FieldDoesNotExist from telemeta.models.core import DurationField, Duration, WeakForeignKey, EnhancedModel, \ CharField, TextField, IntegerField, BooleanField, \ DateTimeField, FileField, ForeignKey, FloatField, DateField from telemeta.models import dublincore as dc +from django.utils.translation import ugettext_lazy as _ class ModelCore(EnhancedModel): @@ -114,6 +116,16 @@ class ModelCore(EnhancedModel): fields_list.append({'name': field.name, 'value': getattr(self, field.name)}) return fields_list + @classmethod + def field_label(cls, field_name): + try: + return cls._meta.get_field(field_name).verbose_name + except FieldDoesNotExist: + try: + return getattr(cls, field_name).verbose_name + except AttributeError: + return field_name + class Meta: abstract = True @@ -135,43 +147,54 @@ class MediaCollection(MediaResource): unpublished_code_regex = 'CNRSMH_I_[0-9]{4}_[0-9]{3}' code_regex = '(?:%s|%s)' % (published_code_regex, unpublished_code_regex) - reference = CharField(unique=True, null=True) - physical_format = WeakForeignKey('PhysicalFormat', related_name="collections") - old_code = CharField(unique=True, null=True) - code = CharField(unique=True, required=True) - title = CharField(required=True) - alt_title = CharField() - physical_items_num = IntegerField(default=0) - publishing_status = WeakForeignKey('PublishingStatus', related_name="collections") - creator = CharField() - booklet_author = CharField() - booklet_description = TextField() - collector = CharField() - collector_is_creator = BooleanField() - publisher = WeakForeignKey('Publisher', related_name="collections") - is_published = BooleanField() - year_published = IntegerField() - publisher_collection = WeakForeignKey('PublisherCollection', related_name="collections") - publisher_serial = CharField() - external_references = TextField() - acquisition_mode = WeakForeignKey('AcquisitionMode', related_name="collections") - comment = TextField() - metadata_author = WeakForeignKey('MetadataAuthor', related_name="collections") - metadata_writer = WeakForeignKey('MetadataWriter', related_name="collections") - legal_rights = WeakForeignKey('LegalRight', related_name="collections") - alt_ids = CharField() - recorded_from_year = IntegerField() - recorded_to_year = IntegerField() - recording_context = WeakForeignKey('RecordingContext', related_name="collections") - approx_duration = DurationField() - doctype_code = IntegerField() - travail = CharField() - state = TextField() - cnrs_contributor = CharField() - items_done = CharField() - a_informer_07_03 = CharField() - ad_conversion = WeakForeignKey('AdConversion', related_name='collections') - public_access = CharField(choices=PUBLIC_ACCESS_CHOICES, max_length=16, default="metadata") + reference = CharField(_('reference'), unique=True, null=True) + physical_format = WeakForeignKey('PhysicalFormat', related_name="collections", + verbose_name=_('archive format')) + old_code = CharField(_('old code'), unique=True, null=True) + code = CharField(_('code'), unique=True, required=True) + title = CharField(_('title'), required=True) + alt_title = CharField(_('original title / translation')) + physical_items_num = IntegerField(_('number of components (medium / piece)')) + publishing_status = WeakForeignKey('PublishingStatus', related_name="collections", + verbose_name=_('secondary edition')) + creator = CharField(_('depositor / contributor')) + booklet_author = CharField(_('author of published notice')) + booklet_description = TextField(_('related documentation')) + collector = CharField(_('collector')) + collector_is_creator = BooleanField(_('collector identical to depositor')) + publisher = WeakForeignKey('Publisher', related_name="collections", + verbose_name=_('publisher / status')) + is_published = BooleanField(_('published')) + year_published = IntegerField(_('year published')) + publisher_collection = WeakForeignKey('PublisherCollection', related_name="collections", + verbose_name=_('publisher collection')) + publisher_serial = CharField(_('publisher serial number')) + external_references = TextField(_('bibliographic references')) + acquisition_mode = WeakForeignKey('AcquisitionMode', related_name="collections", + verbose_name=_('mode of acquisition')) + comment = TextField(_('comment')) + metadata_author = WeakForeignKey('MetadataAuthor', related_name="collections", + verbose_name=_('record author')) + metadata_writer = WeakForeignKey('MetadataWriter', related_name="collections", + verbose_name=_('record writer')) + legal_rights = WeakForeignKey('LegalRight', related_name="collections", + verbose_name=_('legal rights')) + alt_ids = CharField(_('copies')) + recorded_from_year = IntegerField(_('recording year (from)')) + recorded_to_year = IntegerField(_('recording year (until)')) + recording_context = WeakForeignKey('RecordingContext', related_name="collections", + verbose_name=_('recording context')) + approx_duration = DurationField(_('approximative duration')) + doctype_code = IntegerField(_('document type')) + travail = CharField(_('archiver notes')) + state = TextField(_('status')) + cnrs_contributor = CharField(_('CNRS depositor')) + items_done = CharField(_('items finished')) + a_informer_07_03 = CharField(_('a_informer_07_03')) + ad_conversion = WeakForeignKey('AdConversion', related_name='collections', + verbose_name=_('A/D conversion')) + public_access = CharField(_('public access'), choices=PUBLIC_ACCESS_CHOICES, + max_length=16, default="metadata") objects = query.MediaCollectionManager() @@ -193,7 +216,7 @@ class MediaCollection(MediaResource): def __name_cmp(self, obj1, obj2): return unaccent_icmp(obj1.name, obj2.name) - def get_countries(self): + def countries(self): "Return the countries of the items" countries = [] items = self.items.all() @@ -206,8 +229,9 @@ class MediaCollection(MediaResource): countries.sort(self.__name_cmp) return countries + countries.verbose_name = _("states / nations") - def get_ethnic_groups(self): + def ethnic_groups(self): "Return the ethnic groups of the items" groups = [] items = self.items.all() @@ -218,6 +242,15 @@ class MediaCollection(MediaResource): groups.sort(self.__name_cmp) return groups + ethnic_groups.verbose_name = _('populations / social groups') + + def computed_duration(self): + duration = Duration() + for item in self.items.all(): + duration += item.computed_duration() + + return duration + computed_duration.verbose_name = _('computed duration') def is_valid_code(self, code): "Check if the collection code is well formed" @@ -250,33 +283,37 @@ class MediaItem(MediaResource): unpublished_code_regex = MediaCollection.unpublished_code_regex + '_[0-9]{2,3}(?:_[0-9]{2}){0,2}' code_regex = '(?:%s|%s)' % (published_code_regex, unpublished_code_regex) - collection = ForeignKey('MediaCollection', related_name="items") - track = CharField() - old_code = CharField(unique=True, null=True) - code = CharField(unique=True, null=True) - approx_duration = DurationField() - recorded_from_date = DateField() - recorded_to_date = DateField() - location = WeakForeignKey('Location', related_name="items", - db_column='location_name') - location_comment = CharField() - ethnic_group = WeakForeignKey('EthnicGroup', related_name="items") - title = CharField(required=True) - alt_title = CharField() - author = CharField() - vernacular_style = WeakForeignKey('VernacularStyle', related_name="items") - context_comment = TextField() - external_references = TextField() - moda_execut = CharField() - copied_from_item = WeakForeignKey('self', related_name="copies") - collector = CharField() - cultural_area = CharField() - generic_style = WeakForeignKey('GenericStyle', related_name="items") - collector_selection = CharField() - creator_reference = CharField() - comment = TextField() - file = FileField(upload_to='items/%Y/%m/%d', db_column="filename") - public_access = CharField(choices=PUBLIC_ACCESS_CHOICES, max_length=16, default="metadata") + collection = ForeignKey('MediaCollection', related_name="items", + verbose_name=_('collection')) + track = CharField(_('item number')) + old_code = CharField(_('old code'), unique=True, null=True) + code = CharField(_('code'), unique=True, null=True) + approx_duration = DurationField(_('approximative duration')) + recorded_from_date = DateField(_('recording date (from)')) + recorded_to_date = DateField(_('recording date (until)')) + location = WeakForeignKey('Location', related_name="items", + db_column='location_name', verbose_name=_('location')) + location_comment = CharField(_('location comment')) + ethnic_group = WeakForeignKey('EthnicGroup', related_name="items", + verbose_name=_('population / social group')) + title = CharField(_('title'), required=True) + alt_title = CharField(_('original title / translation')) + author = CharField(_('author')) + vernacular_style = WeakForeignKey('VernacularStyle', related_name="items", + verbose_name=_('vernacular name')) + context_comment = TextField(_('comments')) + external_references = TextField(_('published reference')) + moda_execut = CharField(_('moda_execut')) + copied_from_item = WeakForeignKey('self', related_name="copies", verbose_name=_('copy of')) + collector = CharField(_('collector')) + cultural_area = CharField(_('cultural area')) + generic_style = WeakForeignKey('GenericStyle', related_name="items", + verbose_name=_('generic name')) + collector_selection = CharField(_('collector selection')) + creator_reference = CharField(_('depositor reference')) + comment = TextField(_('comment')) + file = FileField(_('file'), upload_to='items/%Y/%m/%d', db_column="filename") + public_access = CharField(_('public access'), choices=PUBLIC_ACCESS_CHOICES, max_length=16, default="metadata") objects = query.MediaItemManager() @@ -316,7 +353,7 @@ class MediaItem(MediaResource): % (self.code, self.collection.code)) super(MediaItem, self).save(force_insert, force_update, using) - def duration(self): + def computed_duration(self): "Tell the length in seconds of this item media data" # FIXME: use TimeSide? seconds = 0 @@ -326,10 +363,9 @@ class MediaItem(MediaResource): seconds = media.getnframes() / media.getframerate() media.close() - if seconds: - return Duration(seconds=seconds) + return Duration(seconds=seconds) - return self.approx_duration + computed_duration.verbose_name = _('computed duration') def __unicode__(self): if self.code: @@ -339,10 +375,10 @@ class MediaItem(MediaResource): class MediaPart(MediaResource): "Describe an item part" element_type = 'part' - item = ForeignKey('MediaItem', related_name="parts") - title = CharField(required=True) - start = FloatField(required=True) - end = FloatField(required=True) + item = ForeignKey('MediaItem', related_name="parts", verbose_name=_('item')) + title = CharField(_('title'), required=True) + start = FloatField(_('start'), required=True) + end = FloatField(_('end'), required=True) class Meta(MetaCore): db_table = 'media_parts' @@ -352,7 +388,7 @@ class MediaPart(MediaResource): class Enumeration(ModelCore): "Abstract enumerations base class" - value = CharField(required=True, unique=True) + value = CharField(_('value'), required=True, unique=True) def __unicode__(self): return self.value @@ -422,7 +458,7 @@ class GenericStyle(Enumeration): class Instrument(ModelCore): "Instrument used in the item" - name = CharField(required=True) + name = CharField(_('name'), required=True) class Meta(MetaCore): db_table = 'instruments' @@ -432,7 +468,7 @@ class Instrument(ModelCore): class InstrumentAlias(ModelCore): "Instrument other name" - name = CharField(required=True) + name = CharField(_('name'), required=True) class Meta(MetaCore): db_table = 'instrument_aliases' @@ -442,8 +478,10 @@ class InstrumentAlias(ModelCore): class InstrumentRelation(ModelCore): "Instrument family" - instrument = ForeignKey('Instrument', related_name="parent_relation") - parent_instrument = ForeignKey('Instrument', related_name="child_relation") + instrument = ForeignKey('Instrument', related_name="parent_relation", + verbose_name=_('instrument')) + parent_instrument = ForeignKey('Instrument', related_name="child_relation", + verbose_name=_('parent instrument')) class Meta(MetaCore): db_table = 'instrument_relations' @@ -451,8 +489,10 @@ class InstrumentRelation(ModelCore): class InstrumentAliasRelation(ModelCore): "Instrument family other name" - alias = ForeignKey('InstrumentAlias', related_name="other_name") - instrument = ForeignKey('InstrumentAlias', related_name="relation") + alias = ForeignKey('InstrumentAlias', related_name="other_name", + verbose_name=_('alias')) + instrument = ForeignKey('InstrumentAlias', related_name="relation", + verbose_name=_('instrument')) class Meta(MetaCore): db_table = 'instrument_alias_relations' @@ -460,11 +500,14 @@ class InstrumentAliasRelation(ModelCore): class MediaItemPerformance(ModelCore): "Item performance" - media_item = ForeignKey('MediaItem', related_name="performances") - instrument = WeakForeignKey('Instrument', related_name="performances") - alias = WeakForeignKey('InstrumentAlias', related_name="performances") - instruments_num = CharField() - musicians = CharField() + media_item = ForeignKey('MediaItem', related_name="performances", + verbose_name=_('item')) + instrument = WeakForeignKey('Instrument', related_name="performances", + verbose_name=_('instrument')) + alias = WeakForeignKey('InstrumentAlias', related_name="performances", + verbose_name=_('alias')) + instruments_num = CharField(_('instruments num')) + musicians = CharField(_('interprets')) class Meta(MetaCore): db_table = 'media_item_performances' @@ -473,12 +516,12 @@ class User(ModelCore): "Telemeta user" LEVEL_CHOICES = (('user', 'user'), ('maintainer', 'maintainer'), ('admin', 'admin')) - username = CharField(primary_key=True, max_length=64, required=True) - level = CharField(choices=LEVEL_CHOICES, max_length=32, required=True) - first_name = CharField() - last_name = CharField() - phone = CharField() - email = CharField() + username = CharField(_('username'), primary_key=True, max_length=64, required=True) + level = CharField(_('level'), choices=LEVEL_CHOICES, max_length=32, required=True) + first_name = CharField(_('first name')) + last_name = CharField(_('last name')) + phone = CharField(_('phone')) + email = CharField(_('email')) class Meta(MetaCore): db_table = 'users' @@ -489,7 +532,7 @@ class User(ModelCore): class Playlist(ModelCore): "Item or collection playlist" owner_username = ForeignKey('User', related_name="playlists", db_column="owner_username") - name = CharField(required=True) + name = CharField(_('name'), required=True) class Meta(MetaCore): db_table = 'playlists' @@ -501,9 +544,9 @@ class PlaylistResource(ModelCore): "Playlist components" RESOURCE_TYPE_CHOICES = (('item', 'item'), ('collection', 'collection')) - playlist = ForeignKey('Playlist', related_name="resources") - resource_type = CharField(choices=RESOURCE_TYPE_CHOICES, required=True) - resource = IntegerField(required=True) + playlist = ForeignKey('Playlist', related_name="resources", verbose_name=_('playlist')) + resource_type = CharField(_('resource type'), choices=RESOURCE_TYPE_CHOICES, required=True) + resource = IntegerField(_('resource'), required=True) class Meta(MetaCore): db_table = 'playlist_resources' @@ -512,12 +555,12 @@ class Location(ModelCore): "Item location" TYPE_CHOICES = (('country', 'country'), ('continent', 'continent'), ('other', 'other')) - name = CharField(primary_key=True, max_length=150, required=True) - type = CharField(choices=TYPE_CHOICES, max_length=16, required=True) - complete_type = ForeignKey('LocationType', related_name="types") - current_name = WeakForeignKey('self', related_name="past_names", - db_column="current_name") - is_authoritative = BooleanField() + name = CharField(_('name'), primary_key=True, max_length=150, required=True) + type = CharField(_('type'), choices=TYPE_CHOICES, max_length=16, required=True) + complete_type = ForeignKey('LocationType', related_name="types", verbose_name=_('complete type')) + current_name = WeakForeignKey('self', related_name="past_names", db_column="current_name", + verbose_name=_('current name')) + is_authoritative = BooleanField(_('authoritative')) def parent(self): relations = self.parent_relations.all() @@ -559,18 +602,18 @@ class Location(ModelCore): class LocationType(ModelCore): "Location type of an item location" - id = CharField(max_length=64, primary_key=True, required=True) - name = CharField(max_length=150, required=True) + id = CharField(_('identifier'), max_length=64, primary_key=True, required=True) + name = CharField(_('name'), max_length=150, required=True) class Meta(MetaCore): db_table = 'location_types' class LocationAlias(ModelCore): "Location other name" - location = ForeignKey('Location', related_name="aliases", - db_column="location_name", max_length=150) - alias = CharField(max_length=150, required=True) - is_authoritative = BooleanField() + location = ForeignKey('Location', related_name="aliases", db_column="location_name", + max_length=150, verbose_name=_('location')) + alias = CharField(_('alias'), max_length=150, required=True) + is_authoritative = BooleanField(_('authoritative')) def __unicode__(self): return self.alias @@ -581,10 +624,10 @@ class LocationAlias(ModelCore): class LocationRelation(ModelCore): "Location family" - location = ForeignKey('Location', related_name="parent_relations", - db_column="location_name", max_length=150) - parent_location = ForeignKey('Location', related_name="child_relations", - db_column="parent_location_name", null=True, max_length=150) + location = ForeignKey('Location', related_name="parent_relations", + db_column="location_name", max_length=150, verbose_name=_('location')) + parent_location = ForeignKey('Location', related_name="child_relations", db_column="parent_location_name", + null=True, max_length=150, verbose_name=_('parent location')) is_authoritative = BooleanField() class Meta(MetaCore): @@ -598,8 +641,8 @@ class ContextKeyword(Enumeration): class MediaItemKeyword(ModelCore): "Item keyword" - item = ForeignKey('MediaItem') - keyword = ForeignKey('ContextKeyword') + item = ForeignKey('MediaItem', verbose_name=_('item')) + keyword = ForeignKey('ContextKeyword', verbose_name=_('keyword')) class Meta(MetaCore): db_table = 'media_item_keywords' @@ -613,8 +656,8 @@ class Publisher(Enumeration): class PublisherCollection(ModelCore): "Collection which belongs to publisher" - publisher = ForeignKey('Publisher', related_name="publisher_collections") - value = CharField(required=True) + publisher = ForeignKey('Publisher', related_name="publisher_collections", verbose_name=_('publisher')) + value = CharField(_('value'), required=True) def __unicode__(self): return self.value @@ -627,11 +670,11 @@ class Revision(ModelCore): ELEMENT_TYPE_CHOICES = (('collection', 'collection'), ('item', 'item'), ('part', 'part')) CHANGE_TYPE_CHOICES = (('import', 'import'), ('create', 'create'), ('update', 'update'), ('delete','delete')) - element_type = CharField(choices=ELEMENT_TYPE_CHOICES, max_length=16, required=True) - element_id = IntegerField(required=True) - change_type = CharField(choices=CHANGE_TYPE_CHOICES, max_length=16, required=True) - time = DateTimeField(auto_now_add=True) - user = ForeignKey('User', db_column='username', related_name="revisions") + element_type = CharField(_('element type'), choices=ELEMENT_TYPE_CHOICES, max_length=16, required=True) + element_id = IntegerField(_('element identifier'), required=True) + change_type = CharField(_('modification type'), choices=CHANGE_TYPE_CHOICES, max_length=16, required=True) + time = DateTimeField(_('time'), auto_now_add=True) + user = ForeignKey('User', db_column='username', related_name="revisions", verbose_name=_('user')) @classmethod def touch(cls, element, user): @@ -654,7 +697,7 @@ class Revision(ModelCore): class EthnicGroup(ModelCore): "Item ethnic group" - name = CharField(required=True) + name = CharField(_('name'), required=True) class Meta(MetaCore): db_table = 'ethnic_groups' @@ -664,8 +707,8 @@ class EthnicGroup(ModelCore): class EthnicGroupAlias(ModelCore): "Item ethnic group other name" - ethnic_group = ForeignKey('EthnicGroup', related_name="aliases") - name = CharField(required=True) + ethnic_group = ForeignKey('EthnicGroup', related_name="aliases", verbose_name=_('population / social group')) + name = CharField(_('name'), required=True) class Meta(MetaCore): db_table = 'ethnic_group_aliases' diff --git a/telemeta/models/dublincore.py b/telemeta/models/dublincore.py index 2718f80c..5c833371 100644 --- a/telemeta/models/dublincore.py +++ b/telemeta/models/dublincore.py @@ -144,18 +144,13 @@ def express_collection(collection): else: creator = Element('creator', collection.creator) - duration = Duration() + duration = max(collection.approx_duration, collection.computed_duration()) parts = [] for item in collection.items.all(): - duration += item.duration() - id = media_identifier(item) if id: parts.append(Element('relation', id, 'hasPart', item)) - if duration < collection.approx_duration: - duration = collection.approx_duration - resource = Resource( Element('identifier', media_identifier(collection), related=collection), Element('type', 'Collection'), @@ -220,7 +215,8 @@ def express_item(item): Element('coverage', item.location_comment, 'spatial'), Element('rights', item.collection.legal_rights, 'license'), Element('rights', media_access_rights(item.collection), 'accessRights'), - Element('format', item.duration(), 'extent'), + + Element('format', max(item.approx_duration, item.computed_duration()), 'extent'), Element('format', item.collection.physical_format, 'medium'), #FIXME: audio mime types are missing, Element('relation', media_identifier(item.collection), 'isPartOf', item.collection) diff --git a/telemeta/templates/telemeta_default/base.html b/telemeta/templates/telemeta_default/base.html index 906666f1..8dbb01c2 100644 --- a/telemeta/templates/telemeta_default/base.html +++ b/telemeta/templates/telemeta_default/base.html @@ -16,11 +16,6 @@ {% load i18n %} {% load telemeta_utils %} -
{% endif %} @@ -53,115 +44,100 @@
{% block general_info %}
- {% if collection.creator %}
Auteur / Cédant
{{ collection.creator }}
{% endif %} - - {% if collection.is_published %} - {% if collection.date_published %}
Date
{{ collection.date_published }}
{% endif %} - {% else %} - {% if collection.annee_enr %}
Date
{{ collection.annee_enr }}
{% endif %} - {% endif %} - - {% if collection.title %}
Titre
{{ collection.title }}
{% endif %} - {% if collection.native_title %}
Traduction du titre
{{ collection.native_title }}
{% endif %} - {% if collection.duree_approx %}
Durée
{{ collection.duree_approx }}
{% endif %} - - {% if collection.is_published %} - {% if collection.publisher %}
Éditeur
{{ collection.publisher }}
{% endif %} - {% if collection.publisher_reference %}
Référence
{{ collection.publisher_reference }}
{% endif %} + {% dl_field collection.title %} + {% dl_field collection.alt_title %} + {% dl_field collection.creator %} + {% if collection.recorded_from_year %} +
{% trans "Recording year" %}
+
{{ collection.recorded_from_year }} {{ collection.recorded_to_year|prepend:" - " }}
{% endif %} - + {% dl_field collection.year_published %}
{% endblock general_info %}
{% block geoethnic_data %}
-

Données ethnographiques

+

{% trans "Geographic and cultural informations" %}

- - {% if collection.get_countries %} -
État / Nation
{{collection.get_countries|join:", "}}
- {% endif %} - - {% if collection.get_ethnic_groups %} -
Ethnie / Groupe social
{{ collection.get_ethnic_groups|join:", " }}
- {% endif %} - - {% if collection.terrain_ou_autre %}
Contexte de l’enregistrement
{{ collection.terrain_ou_autre }}
{% endif %} - + {% dl_field collection.countries join with ", " %} + {% dl_field collection.ethnic_groups join with ", " %}
{% endblock geoethnic_data %}
- {% if collection.is_published %}
- {% block publication_data %} -
-

Détails du document édité

+ {% block legal_data %} +
+

{% trans "Legal mentions" %}

- {% if collection.publishing_status %}
Réédition
{{ collection.publishing_status }}
{% endif %} - {% if collection.booklet_writer %}
Auteur Notice
{{ collection.booklet_writer }}
{% endif %} - {% if collection.booklet_description %}
Notice
{{ collection.booklet_description }}
{% endif %} + {% dl_field collection.collector %} + {% dl_field collection.publisher %} + {% dl_field collection.publisher_collection %} + {% dl_field collection.publisher_serial %} + {% dl_field collection.booklet_author %} + {% dl_field collection.external_references %} + {% dl_field collection.doctype_code %} + {% dl_field collection.public_access %} + {% dl_field collection.legal_rights %}
-
- {% endblock publication_data %} + {% endblock legal_data %}
- {% endif %}
- {% block document_identification %} -
-

Identification du document

+ {% block archive_data %} +
+

{% trans "Archiving data" %}

- {% if collection.id %}
Cote
{{ collection.id }}
{% endif %} - {% if collection.physical_format %}
Format de l'original
{{ collection.physical_format }}
{% endif %} + {% dl_field collection.acquisition_mode %} + {% dl_field collection.cnrs_contributor %} + {% dl_field collection.metadata_writer %} + {% dl_field collection.booklet_description %} + {% dl_field collection.publishing_status %} + {% dl_field collection.alt_ids %} + {% dl_field collection.comment %} + {% dl_field collection.metadata_writer %} + {% dl_field collection.travail %} + {% dl_field collection.items_done %}
- {% endblock document_identification %} + {% endblock archive_data %}
- {% block document_data %} -
-

Informations documentaires

+ {% block technical_data %} +
+

{% trans "Technical data" %}

- {% if collection.a_informer %}
a informer
{{ collection.a_informer }}
{% endif %} - {% if collection.acquisition_mode %}
acquisition mode
{{ collection.acquisition_mode }}
{% endif %} - {% if collection.champ36 %}
champ36
{{ collection.champ36 }}
{% endif %} - {% if collection.collector %}
collector
{{ collection.collector }}
{% endif %} - {% if collection.comment %}
comment
{{ collection.comment }}
{% endif %} - - {% if collection.deposant_cnrs %}
deposant cnrs
{{ collection.deposant_cnrs }}
{% endif %} - {% if collection.fiches %}
fiches
{{ collection.fiches }}
{% endif %} - {% if collection.is_full_copy %}
is full copy
{{ collection.is_full_copy }}
{% endif %} - {% if collection.is_original %}
is original
{{ collection.is_original }}
{% endif %} - {% if collection.numerisation %}
numerisation
{{ collection.numerisation }}
{% endif %} - {% if collection.physical_items_num %}
physical items num
{{ collection.physical_items_num }}
{% endif %} - {% if collection.publisher_collection %}
publisher collection
{{ collection.publisher_collection }}
{% endif %} - {% if collection.publisher_serial_id %}
publisher serial id
{{ collection.publisher_serial_id }}
{% endif %} - {% if collection.record_author %}
record author
{{ collection.record_author }}
{% endif %} - {% if collection.record_writer %}
record writer
{{ collection.record_writer }}
{% endif %} - {% if collection.ref_biblio %}
ref biblio
{{ collection.ref_biblio }}
{% endif %} - {% if collection.rights %}
rights
{{ collection.rights }}
{% endif %} - {% if collection.travail %}
travail
{{ collection.travail }}
{% endif %} - {% if collection.tri_dibm %}
tri dibm
{{ collection.tri_dibm }}
{% endif %} + {% dl_field collection.code %} + {% dl_field collection.old_code %} +
{% trans "Media type" %}
{% trans "Audio" %}
+ {% dl_field collection.approx_duration %} + {% dl_field collection.computed_duration %} + {% dl_field collection.physical_items_num %} +
{% trans "Number of items" %}
{{ collection.items.count }}
+ {% dl_field collection.physical_format %} + {% dl_field collection.ad_conversion %}
- {% endblock document_data %} + {% endblock technical_data %}

Items

+ {% with collection.items.all as items %} + {% include "telemeta/inc/mediaitem_list.html" %} + {% endwith %} +
{% endblock %} diff --git a/telemeta/templatetags/telemeta_utils.py b/telemeta/templatetags/telemeta_utils.py index 622cec0a..0fb014d4 100644 --- a/telemeta/templatetags/telemeta_utils.py +++ b/telemeta/templatetags/telemeta_utils.py @@ -3,6 +3,9 @@ from django.utils.http import urlquote from telemeta.models import MediaItem, MediaCollection from django.core.urlresolvers import reverse import telemeta.models.dublincore as dc +from django.utils import html +from django import template +from django.utils.text import capfirst register = template.Library() @@ -93,3 +96,60 @@ def to_dublincore(resource): return dc.express_item(resource) else: return dc.express_collection(resource) + +class DescriptionListFieldNode(template.Node): + def __init__(self, variable, join_with = None): + cut = variable.split('.') + self.model = template.Variable('.'.join(cut[:-1])) + self.member = cut[-1] + self.join_with = join_with + + def render(self, context): + try: + model = self.model.resolve(context) + label = html.escape(capfirst(unicode(model.field_label(self.member)))) + try: + value = getattr(model, self.member) + except AttributeError: + value = '' + except template.VariableDoesNotExist: + label = unicode(self.model) + '.' + self.member + value = '' + + try: + value = value() + except TypeError: + pass + if self.join_with: + value = self.join_with.join([unicode(v) for v in value]) + if value: + value = html.escape(unicode(value)) + markup = '
%s
%s
' % (label, value) + return markup + + return '' + +@register.tag +def dl_field(parser, token): + cut = token.split_contents() + join_with = None + try: + tag_name, variable = cut + except ValueError: + try: + tag_name, variable, arg3, arg4, arg5 = cut + if arg3 == 'join' and arg4 == 'with'and arg5[0] == arg5[-1] and arg5[0] in ('"', "'"): + join_with = arg5[1:-1] + else: + raise ValueError() + except ValueError: + raise template.TemplateSyntaxError("%r tag: invalid arguments" + % token.contents.split()[0]) + + return DescriptionListFieldNode(variable, join_with=join_with) + +@register.filter +def prepend(str, prefix): + if str: + return prefix + unicode(str) + return '' -- 2.39.5