Changeset 512
- Timestamp:
- 01/27/10 14:21:03 (6 weeks ago)
- Location:
- trunk/telemeta
- Files:
-
- 5 added
- 6 modified
-
locale (added)
-
locale/fr (added)
-
locale/fr/LC_MESSAGES (added)
-
locale/fr/LC_MESSAGES/django.mo (added)
-
locale/fr/LC_MESSAGES/django.po (added)
-
models/core.py (modified) (1 diff)
-
models/crem.py (modified) (28 diffs)
-
models/dublincore.py (modified) (2 diffs)
-
templates/telemeta_default/base.html (modified) (1 diff)
-
templates/telemeta_default/collection_detail.html (modified) (6 diffs)
-
templatetags/telemeta_utils.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/telemeta/models/core.py
r511 r512 134 134 135 135 def __init__(self, *args, **kwargs): 136 super(DurationField, self).__init__( args, **normalize_field(kwargs, '00:00'))136 super(DurationField, self).__init__(*args, **normalize_field(kwargs, '00:00')) 137 137 138 138 def get_internal_type(self): -
trunk/telemeta/models/crem.py
r511 r512 39 39 from telemeta.util.unaccent import unaccent_icmp 40 40 import re 41 from django.db.models import FieldDoesNotExist 41 42 from telemeta.models.core import DurationField, Duration, WeakForeignKey, EnhancedModel, \ 42 43 CharField, TextField, IntegerField, BooleanField, \ 43 44 DateTimeField, FileField, ForeignKey, FloatField, DateField 44 45 from telemeta.models import dublincore as dc 46 from django.utils.translation import ugettext_lazy as _ 45 47 46 48 class ModelCore(EnhancedModel): … … 115 117 return fields_list 116 118 119 @classmethod 120 def field_label(cls, field_name): 121 try: 122 return cls._meta.get_field(field_name).verbose_name 123 except FieldDoesNotExist: 124 try: 125 return getattr(cls, field_name).verbose_name 126 except AttributeError: 127 return field_name 128 117 129 class Meta: 118 130 abstract = True … … 136 148 code_regex = '(?:%s|%s)' % (published_code_regex, unpublished_code_regex) 137 149 138 reference = CharField(unique=True, null=True) 139 physical_format = WeakForeignKey('PhysicalFormat', related_name="collections") 140 old_code = CharField(unique=True, null=True) 141 code = CharField(unique=True, required=True) 142 title = CharField(required=True) 143 alt_title = CharField() 144 physical_items_num = IntegerField(default=0) 145 publishing_status = WeakForeignKey('PublishingStatus', related_name="collections") 146 creator = CharField() 147 booklet_author = CharField() 148 booklet_description = TextField() 149 collector = CharField() 150 collector_is_creator = BooleanField() 151 publisher = WeakForeignKey('Publisher', related_name="collections") 152 is_published = BooleanField() 153 year_published = IntegerField() 154 publisher_collection = WeakForeignKey('PublisherCollection', related_name="collections") 155 publisher_serial = CharField() 156 external_references = TextField() 157 acquisition_mode = WeakForeignKey('AcquisitionMode', related_name="collections") 158 comment = TextField() 159 metadata_author = WeakForeignKey('MetadataAuthor', related_name="collections") 160 metadata_writer = WeakForeignKey('MetadataWriter', related_name="collections") 161 legal_rights = WeakForeignKey('LegalRight', related_name="collections") 162 alt_ids = CharField() 163 recorded_from_year = IntegerField() 164 recorded_to_year = IntegerField() 165 recording_context = WeakForeignKey('RecordingContext', related_name="collections") 166 approx_duration = DurationField() 167 doctype_code = IntegerField() 168 travail = CharField() 169 state = TextField() 170 cnrs_contributor = CharField() 171 items_done = CharField() 172 a_informer_07_03 = CharField() 173 ad_conversion = WeakForeignKey('AdConversion', related_name='collections') 174 public_access = CharField(choices=PUBLIC_ACCESS_CHOICES, max_length=16, default="metadata") 150 reference = CharField(_('reference'), unique=True, null=True) 151 physical_format = WeakForeignKey('PhysicalFormat', related_name="collections", 152 verbose_name=_('archive format')) 153 old_code = CharField(_('old code'), unique=True, null=True) 154 code = CharField(_('code'), unique=True, required=True) 155 title = CharField(_('title'), required=True) 156 alt_title = CharField(_('original title / translation')) 157 physical_items_num = IntegerField(_('number of components (medium / piece)')) 158 publishing_status = WeakForeignKey('PublishingStatus', related_name="collections", 159 verbose_name=_('secondary edition')) 160 creator = CharField(_('depositor / contributor')) 161 booklet_author = CharField(_('author of published notice')) 162 booklet_description = TextField(_('related documentation')) 163 collector = CharField(_('collector')) 164 collector_is_creator = BooleanField(_('collector identical to depositor')) 165 publisher = WeakForeignKey('Publisher', related_name="collections", 166 verbose_name=_('publisher / status')) 167 is_published = BooleanField(_('published')) 168 year_published = IntegerField(_('year published')) 169 publisher_collection = WeakForeignKey('PublisherCollection', related_name="collections", 170 verbose_name=_('publisher collection')) 171 publisher_serial = CharField(_('publisher serial number')) 172 external_references = TextField(_('bibliographic references')) 173 acquisition_mode = WeakForeignKey('AcquisitionMode', related_name="collections", 174 verbose_name=_('mode of acquisition')) 175 comment = TextField(_('comment')) 176 metadata_author = WeakForeignKey('MetadataAuthor', related_name="collections", 177 verbose_name=_('record author')) 178 metadata_writer = WeakForeignKey('MetadataWriter', related_name="collections", 179 verbose_name=_('record writer')) 180 legal_rights = WeakForeignKey('LegalRight', related_name="collections", 181 verbose_name=_('legal rights')) 182 alt_ids = CharField(_('copies')) 183 recorded_from_year = IntegerField(_('recording year (from)')) 184 recorded_to_year = IntegerField(_('recording year (until)')) 185 recording_context = WeakForeignKey('RecordingContext', related_name="collections", 186 verbose_name=_('recording context')) 187 approx_duration = DurationField(_('approximative duration')) 188 doctype_code = IntegerField(_('document type')) 189 travail = CharField(_('archiver notes')) 190 state = TextField(_('status')) 191 cnrs_contributor = CharField(_('CNRS depositor')) 192 items_done = CharField(_('items finished')) 193 a_informer_07_03 = CharField(_('a_informer_07_03')) 194 ad_conversion = WeakForeignKey('AdConversion', related_name='collections', 195 verbose_name=_('A/D conversion')) 196 public_access = CharField(_('public access'), choices=PUBLIC_ACCESS_CHOICES, 197 max_length=16, default="metadata") 175 198 176 199 objects = query.MediaCollectionManager() … … 194 217 return unaccent_icmp(obj1.name, obj2.name) 195 218 196 def get_countries(self):219 def countries(self): 197 220 "Return the countries of the items" 198 221 countries = [] … … 207 230 208 231 return countries 209 210 def get_ethnic_groups(self): 232 countries.verbose_name = _("states / nations") 233 234 def ethnic_groups(self): 211 235 "Return the ethnic groups of the items" 212 236 groups = [] … … 219 243 220 244 return groups 245 ethnic_groups.verbose_name = _('populations / social groups') 246 247 def computed_duration(self): 248 duration = Duration() 249 for item in self.items.all(): 250 duration += item.computed_duration() 251 252 return duration 253 computed_duration.verbose_name = _('computed duration') 221 254 222 255 def is_valid_code(self, code): … … 251 284 code_regex = '(?:%s|%s)' % (published_code_regex, unpublished_code_regex) 252 285 253 collection = ForeignKey('MediaCollection', related_name="items") 254 track = CharField() 255 old_code = CharField(unique=True, null=True) 256 code = CharField(unique=True, null=True) 257 approx_duration = DurationField() 258 recorded_from_date = DateField() 259 recorded_to_date = DateField() 260 location = WeakForeignKey('Location', related_name="items", 261 db_column='location_name') 262 location_comment = CharField() 263 ethnic_group = WeakForeignKey('EthnicGroup', related_name="items") 264 title = CharField(required=True) 265 alt_title = CharField() 266 author = CharField() 267 vernacular_style = WeakForeignKey('VernacularStyle', related_name="items") 268 context_comment = TextField() 269 external_references = TextField() 270 moda_execut = CharField() 271 copied_from_item = WeakForeignKey('self', related_name="copies") 272 collector = CharField() 273 cultural_area = CharField() 274 generic_style = WeakForeignKey('GenericStyle', related_name="items") 275 collector_selection = CharField() 276 creator_reference = CharField() 277 comment = TextField() 278 file = FileField(upload_to='items/%Y/%m/%d', db_column="filename") 279 public_access = CharField(choices=PUBLIC_ACCESS_CHOICES, max_length=16, default="metadata") 286 collection = ForeignKey('MediaCollection', related_name="items", 287 verbose_name=_('collection')) 288 track = CharField(_('item number')) 289 old_code = CharField(_('old code'), unique=True, null=True) 290 code = CharField(_('code'), unique=True, null=True) 291 approx_duration = DurationField(_('approximative duration')) 292 recorded_from_date = DateField(_('recording date (from)')) 293 recorded_to_date = DateField(_('recording date (until)')) 294 location = WeakForeignKey('Location', related_name="items", 295 db_column='location_name', verbose_name=_('location')) 296 location_comment = CharField(_('location comment')) 297 ethnic_group = WeakForeignKey('EthnicGroup', related_name="items", 298 verbose_name=_('population / social group')) 299 title = CharField(_('title'), required=True) 300 alt_title = CharField(_('original title / translation')) 301 author = CharField(_('author')) 302 vernacular_style = WeakForeignKey('VernacularStyle', related_name="items", 303 verbose_name=_('vernacular name')) 304 context_comment = TextField(_('comments')) 305 external_references = TextField(_('published reference')) 306 moda_execut = CharField(_('moda_execut')) 307 copied_from_item = WeakForeignKey('self', related_name="copies", verbose_name=_('copy of')) 308 collector = CharField(_('collector')) 309 cultural_area = CharField(_('cultural area')) 310 generic_style = WeakForeignKey('GenericStyle', related_name="items", 311 verbose_name=_('generic name')) 312 collector_selection = CharField(_('collector selection')) 313 creator_reference = CharField(_('depositor reference')) 314 comment = TextField(_('comment')) 315 file = FileField(_('file'), upload_to='items/%Y/%m/%d', db_column="filename") 316 public_access = CharField(_('public access'), choices=PUBLIC_ACCESS_CHOICES, max_length=16, default="metadata") 280 317 281 318 objects = query.MediaItemManager() … … 317 354 super(MediaItem, self).save(force_insert, force_update, using) 318 355 319 def duration(self):356 def computed_duration(self): 320 357 "Tell the length in seconds of this item media data" 321 358 # FIXME: use TimeSide? … … 327 364 media.close() 328 365 329 if seconds: 330 return Duration(seconds=seconds) 331 332 return self.approx_duration 366 return Duration(seconds=seconds) 367 368 computed_duration.verbose_name = _('computed duration') 333 369 334 370 def __unicode__(self): … … 340 376 "Describe an item part" 341 377 element_type = 'part' 342 item = ForeignKey('MediaItem', related_name="parts" )343 title = CharField( required=True)344 start = FloatField( required=True)345 end = FloatField( required=True)378 item = ForeignKey('MediaItem', related_name="parts", verbose_name=_('item')) 379 title = CharField(_('title'), required=True) 380 start = FloatField(_('start'), required=True) 381 end = FloatField(_('end'), required=True) 346 382 347 383 class Meta(MetaCore): … … 353 389 class Enumeration(ModelCore): 354 390 "Abstract enumerations base class" 355 value = CharField( required=True, unique=True)391 value = CharField(_('value'), required=True, unique=True) 356 392 357 393 def __unicode__(self): … … 423 459 class Instrument(ModelCore): 424 460 "Instrument used in the item" 425 name = CharField( required=True)461 name = CharField(_('name'), required=True) 426 462 427 463 class Meta(MetaCore): … … 433 469 class InstrumentAlias(ModelCore): 434 470 "Instrument other name" 435 name = CharField( required=True)471 name = CharField(_('name'), required=True) 436 472 437 473 class Meta(MetaCore): … … 443 479 class InstrumentRelation(ModelCore): 444 480 "Instrument family" 445 instrument = ForeignKey('Instrument', related_name="parent_relation") 446 parent_instrument = ForeignKey('Instrument', related_name="child_relation") 481 instrument = ForeignKey('Instrument', related_name="parent_relation", 482 verbose_name=_('instrument')) 483 parent_instrument = ForeignKey('Instrument', related_name="child_relation", 484 verbose_name=_('parent instrument')) 447 485 448 486 class Meta(MetaCore): … … 452 490 class InstrumentAliasRelation(ModelCore): 453 491 "Instrument family other name" 454 alias = ForeignKey('InstrumentAlias', related_name="other_name") 455 instrument = ForeignKey('InstrumentAlias', related_name="relation") 492 alias = ForeignKey('InstrumentAlias', related_name="other_name", 493 verbose_name=_('alias')) 494 instrument = ForeignKey('InstrumentAlias', related_name="relation", 495 verbose_name=_('instrument')) 456 496 457 497 class Meta(MetaCore): … … 461 501 class MediaItemPerformance(ModelCore): 462 502 "Item performance" 463 media_item = ForeignKey('MediaItem', related_name="performances") 464 instrument = WeakForeignKey('Instrument', related_name="performances") 465 alias = WeakForeignKey('InstrumentAlias', related_name="performances") 466 instruments_num = CharField() 467 musicians = CharField() 503 media_item = ForeignKey('MediaItem', related_name="performances", 504 verbose_name=_('item')) 505 instrument = WeakForeignKey('Instrument', related_name="performances", 506 verbose_name=_('instrument')) 507 alias = WeakForeignKey('InstrumentAlias', related_name="performances", 508 verbose_name=_('alias')) 509 instruments_num = CharField(_('instruments num')) 510 musicians = CharField(_('interprets')) 468 511 469 512 class Meta(MetaCore): … … 474 517 LEVEL_CHOICES = (('user', 'user'), ('maintainer', 'maintainer'), ('admin', 'admin')) 475 518 476 username = CharField( primary_key=True, max_length=64, required=True)477 level = CharField( choices=LEVEL_CHOICES, max_length=32, required=True)478 first_name = CharField( )479 last_name = CharField( )480 phone = CharField( )481 email = CharField( )519 username = CharField(_('username'), primary_key=True, max_length=64, required=True) 520 level = CharField(_('level'), choices=LEVEL_CHOICES, max_length=32, required=True) 521 first_name = CharField(_('first name')) 522 last_name = CharField(_('last name')) 523 phone = CharField(_('phone')) 524 email = CharField(_('email')) 482 525 483 526 class Meta(MetaCore): … … 490 533 "Item or collection playlist" 491 534 owner_username = ForeignKey('User', related_name="playlists", db_column="owner_username") 492 name = CharField( required=True)535 name = CharField(_('name'), required=True) 493 536 494 537 class Meta(MetaCore): … … 502 545 RESOURCE_TYPE_CHOICES = (('item', 'item'), ('collection', 'collection')) 503 546 504 playlist = ForeignKey('Playlist', related_name="resources" )505 resource_type = CharField( choices=RESOURCE_TYPE_CHOICES, required=True)506 resource = IntegerField( required=True)547 playlist = ForeignKey('Playlist', related_name="resources", verbose_name=_('playlist')) 548 resource_type = CharField(_('resource type'), choices=RESOURCE_TYPE_CHOICES, required=True) 549 resource = IntegerField(_('resource'), required=True) 507 550 508 551 class Meta(MetaCore): … … 513 556 TYPE_CHOICES = (('country', 'country'), ('continent', 'continent'), ('other', 'other')) 514 557 515 name = CharField( primary_key=True, max_length=150, required=True)516 type = CharField( choices=TYPE_CHOICES, max_length=16, required=True)517 complete_type = ForeignKey('LocationType', related_name="types" )518 current_name = WeakForeignKey('self', related_name="past_names", 519 db_column="current_name")520 is_authoritative = BooleanField( )558 name = CharField(_('name'), primary_key=True, max_length=150, required=True) 559 type = CharField(_('type'), choices=TYPE_CHOICES, max_length=16, required=True) 560 complete_type = ForeignKey('LocationType', related_name="types", verbose_name=_('complete type')) 561 current_name = WeakForeignKey('self', related_name="past_names", db_column="current_name", 562 verbose_name=_('current name')) 563 is_authoritative = BooleanField(_('authoritative')) 521 564 522 565 def parent(self): … … 560 603 class LocationType(ModelCore): 561 604 "Location type of an item location" 562 id = CharField( max_length=64, primary_key=True, required=True)563 name = CharField( max_length=150, required=True)605 id = CharField(_('identifier'), max_length=64, primary_key=True, required=True) 606 name = CharField(_('name'), max_length=150, required=True) 564 607 565 608 class Meta(MetaCore): … … 568 611 class LocationAlias(ModelCore): 569 612 "Location other name" 570 location = ForeignKey('Location', related_name="aliases", 571 db_column="location_name", max_length=150)572 alias = CharField( max_length=150, required=True)573 is_authoritative = BooleanField( )613 location = ForeignKey('Location', related_name="aliases", db_column="location_name", 614 max_length=150, verbose_name=_('location')) 615 alias = CharField(_('alias'), max_length=150, required=True) 616 is_authoritative = BooleanField(_('authoritative')) 574 617 575 618 def __unicode__(self): … … 582 625 class LocationRelation(ModelCore): 583 626 "Location family" 584 location = ForeignKey('Location', related_name="parent_relations", 585 db_column="location_name", max_length=150)586 parent_location = ForeignKey('Location', related_name="child_relations", 587 db_column="parent_location_name", null=True, max_length=150)627 location = ForeignKey('Location', related_name="parent_relations", 628 db_column="location_name", max_length=150, verbose_name=_('location')) 629 parent_location = ForeignKey('Location', related_name="child_relations", db_column="parent_location_name", 630 null=True, max_length=150, verbose_name=_('parent location')) 588 631 is_authoritative = BooleanField() 589 632 … … 599 642 class MediaItemKeyword(ModelCore): 600 643 "Item keyword" 601 item = ForeignKey('MediaItem' )602 keyword = ForeignKey('ContextKeyword' )644 item = ForeignKey('MediaItem', verbose_name=_('item')) 645 keyword = ForeignKey('ContextKeyword', verbose_name=_('keyword')) 603 646 604 647 class Meta(MetaCore): … … 614 657 class PublisherCollection(ModelCore): 615 658 "Collection which belongs to publisher" 616 publisher = ForeignKey('Publisher', related_name="publisher_collections" )617 value = CharField( required=True)659 publisher = ForeignKey('Publisher', related_name="publisher_collections", verbose_name=_('publisher')) 660 value = CharField(_('value'), required=True) 618 661 619 662 def __unicode__(self): … … 628 671 CHANGE_TYPE_CHOICES = (('import', 'import'), ('create', 'create'), ('update', 'update'), ('delete','delete')) 629 672 630 element_type = CharField( choices=ELEMENT_TYPE_CHOICES, max_length=16, required=True)631 element_id = IntegerField( required=True)632 change_type = CharField( choices=CHANGE_TYPE_CHOICES, max_length=16, required=True)633 time = DateTimeField( auto_now_add=True)634 user = ForeignKey('User', db_column='username', related_name="revisions" )673 element_type = CharField(_('element type'), choices=ELEMENT_TYPE_CHOICES, max_length=16, required=True) 674 element_id = IntegerField(_('element identifier'), required=True) 675 change_type = CharField(_('modification type'), choices=CHANGE_TYPE_CHOICES, max_length=16, required=True) 676 time = DateTimeField(_('time'), auto_now_add=True) 677 user = ForeignKey('User', db_column='username', related_name="revisions", verbose_name=_('user')) 635 678 636 679 @classmethod … … 655 698 class EthnicGroup(ModelCore): 656 699 "Item ethnic group" 657 name = CharField( required=True)700 name = CharField(_('name'), required=True) 658 701 659 702 class Meta(MetaCore): … … 665 708 class EthnicGroupAlias(ModelCore): 666 709 "Item ethnic group other name" 667 ethnic_group = ForeignKey('EthnicGroup', related_name="aliases" )668 name = CharField( required=True)710 ethnic_group = ForeignKey('EthnicGroup', related_name="aliases", verbose_name=_('population / social group')) 711 name = CharField(_('name'), required=True) 669 712 670 713 class Meta(MetaCore): -
trunk/telemeta/models/dublincore.py
r507 r512 145 145 creator = Element('creator', collection.creator) 146 146 147 duration = Duration()147 duration = max(collection.approx_duration, collection.computed_duration()) 148 148 parts = [] 149 149 for item in collection.items.all(): 150 duration += item.duration()151 152 150 id = media_identifier(item) 153 151 if id: 154 152 parts.append(Element('relation', id, 'hasPart', item)) 155 156 if duration < collection.approx_duration:157 duration = collection.approx_duration158 153 159 154 resource = Resource( … … 221 216 Element('rights', item.collection.legal_rights, 'license'), 222 217 Element('rights', media_access_rights(item.collection), 'accessRights'), 223 Element('format', item.duration(), 'extent'), 218 219 Element('format', max(item.approx_duration, item.computed_duration()), 'extent'), 224 220 Element('format', item.collection.physical_format, 'medium'), 225 221 #FIXME: audio mime types are missing, -
trunk/telemeta/templates/telemeta_default/base.html
r346 r512 17 17 {% load telemeta_utils %} 18 18 <body> 19 <!--20 {% if user.is_authenticated and user.is_staff %}21 <div id="user-tools">{% trans 'Welcome,' %} <strong>{% if user.first_name %}{{ user.first_name|escape }}{% else %}{{ user.username }}{% endif %}</strong>. {% block userlinks %}<a href="doc/">{% trans 'Documentation' %}</a> / <a href="password_change/">{% trans 'Change password' %}</a> / <a href="logout/">{% trans 'Log out' %}</a>{% endblock %}</div>22 {% endif %}23 -->24 19 <div id="layout"> 25 20 <div id="header"> -
trunk/telemeta/templates/telemeta_default/collection_detail.html
r510 r512 1 1 {% extends "telemeta/base.html" %} 2 2 {% load telemeta_utils %} 3 {% load i18n %} 3 4 4 5 {% block extra_javascript %} … … 23 24 (<a href="{% url telemeta-collection-m3u collection.public_id %}">M3U</a>, 24 25 <a href="{% url telemeta-collection-xspf collection.public_id %}">XSPF</a>)</p> 25 {% if 0 %} {# Use 1/0 for alternate player #}26 <!-- This is the XSPF Web Music Player, under the BSD license,27 from: http://musicplayer.sourceforge.net/-->28 <object type="application/x-shockwave-flash" width="362" height="200"29 data="{% url telemeta-swf "xspf_player.swf" %}?playlist_url={% url telemeta-collection-xspf collection.public_id %}">30 <param name="movie"31 value="{% url telemeta-swf "xspf_player.swf" %}?playlist_url={% url telemeta-collection-xspf collection.public_id %}" />32 </object>33 {% else %}34 26 <!-- This is Jeroen Wijering's Flash MP3 Player, 35 27 under CC Attribution-NonCommercial-ShareAlike 2.0 license … … 44 36 so.write('collection_player_c'); 45 37 </script> 46 {% endif %}47 38 </div> 48 39 </div> … … 54 45 {% block general_info %} 55 46 <dl class="listing"> 56 {% if collection.creator %}<dt>Auteur / Cédant</dt><dd>{{ collection.creator }}</dd>{% endif%}57 58 {% if collection.is_published%}59 {% if collection. date_published %}<dt>Date</dt><dd>{{ collection.date_published }}</dd>{% endif%}60 {% else %}61 {% if collection.annee_enr %}<dt>Date</dt><dd>{{ collection.annee_enr }}</dd>{% endif %}47 {% dl_field collection.title %} 48 {% dl_field collection.alt_title %} 49 {% dl_field collection.creator %} 50 {% if collection.recorded_from_year %} 51 <dt>{% trans "Recording year" %}</dt> 52 <dd>{{ collection.recorded_from_year }} {{ collection.recorded_to_year|prepend:" - " }}</dd> 62 53 {% endif %} 63 64 {% if collection.title %}<dt>Titre</dt><dd>{{ collection.title }}</dd>{% endif %} 65 {% if collection.native_title %}<dt>Traduction du titre</dt><dd>{{ collection.native_title }}</dd>{% endif %} 66 {% if collection.duree_approx %}<dt>Durée</dt><dd>{{ collection.duree_approx }}</dd>{% endif %} 67 68 {% if collection.is_published %} 69 {% if collection.publisher %}<dt>Éditeur</dt><dd>{{ collection.publisher }}</dd>{% endif %} 70 {% if collection.publisher_reference %}<dt>Référence</dt><dd>{{ collection.publisher_reference }}</dd>{% endif %} 71 {% endif %} 72 54 {% dl_field collection.year_published %} 73 55 </dl> 74 56 {% endblock general_info %} … … 77 59 {% block geoethnic_data %} 78 60 <div> 79 <h4><a href="#"> Données ethnographiques</a></h4>61 <h4><a href="#">{% trans "Geographic and cultural informations" %}</a></h4> 80 62 <div> 81 63 <dl class="listing"> 82 83 {% if collection.get_countries %} 84 <dt>État / Nation</dt><dd>{{collection.get_countries|join:", "}}</dd> 85 {% endif %} 86 87 {% if collection.get_ethnic_groups %} 88 <dt>Ethnie / Groupe social</dt><dd>{{ collection.get_ethnic_groups|join:", " }}</dd> 89 {% endif %} 90 91 {% if collection.terrain_ou_autre %}<dt>Contexte de l’enregistrement</dt><dd>{{ collection.terrain_ou_autre }}</dd>{% endif %} 92 64 {% dl_field collection.countries join with ", " %} 65 {% dl_field collection.ethnic_groups join with ", " %} 93 66 </dl> 94 67 </div> … … 96 69 {% endblock geoethnic_data %} 97 70 </div> 98 {% if collection.is_published %}99 71 <div class="extraInfos"> 100 {% block publication_data %}101 <div class="folded">102 <h4><a href="#"> Détails du document édité</a></h4>72 {% block legal_data %} 73 <div> 74 <h4><a href="#">{% trans "Legal mentions" %}</a></h4> 103 75 <div> 104 76 <dl class="listing"> 105 {% if collection.publishing_status %}<dt>Réédition</dt><dd>{{ collection.publishing_status }}</dd>{% endif %} 106 {% if collection.booklet_writer %}<dt>Auteur Notice</dt><dd>{{ collection.booklet_writer }}</dd>{% endif %} 107 {% if collection.booklet_description %}<dt>Notice</dt><dd>{{ collection.booklet_description }}</dd>{% endif %} 77 {% dl_field collection.collector %} 78 {% dl_field collection.publisher %} 79 {% dl_field collection.publisher_collection %} 80 {% dl_field collection.publisher_serial %} 81 {% dl_field collection.booklet_author %} 82 {% dl_field collection.external_references %} 83 {% dl_field collection.doctype_code %} 84 {% dl_field collection.public_access %} 85 {% dl_field collection.legal_rights %} 108 86 </dl> 109 87 </div> 110 88 </div> 111 <div class="nett"></div> 112 {% endblock publication_data %} 89 {% endblock legal_data %} 113 90 </div> 114 {% endif %}115 91 <div class="extraInfos"> 116 {% block document_identification%}117 <div class="folded">118 <h4><a href="#"> Identification du document</a></h4>92 {% block archive_data %} 93 <div> 94 <h4><a href="#">{% trans "Archiving data" %}</a></h4> 119 95 <div> 120 96 <dl class="listing"> 121 {% if collection.id %}<dt>Cote</dt><dd>{{ collection.id }}</dd>{% endif %} 122 {% if collection.physical_format %}<dt>Format de l'original</dt><dd>{{ collection.physical_format }}</dd>{% endif %} 97 {% dl_field collection.acquisition_mode %} 98 {% dl_field collection.cnrs_contributor %} 99 {% dl_field collection.metadata_writer %} 100 {% dl_field collection.booklet_description %} 101 {% dl_field collection.publishing_status %} 102 {% dl_field collection.alt_ids %} 103 {% dl_field collection.comment %} 104 {% dl_field collection.metadata_writer %} 105 {% dl_field collection.travail %} 106 {% dl_field collection.items_done %} 123 107 </dl> 124 108 </div> 125 109 </div> 126 {% endblock document_identification%}110 {% endblock archive_data %} 127 111 </div> 128 112 <div class="extraInfos"> 129 {% block document_data %}130 <div class="folded">131 <h4><a href="#"> Informations documentaires</a></h4>113 {% block technical_data %} 114 <div> 115 <h4><a href="#">{% trans "Technical data" %}</a></h4> 132 116 <div> 133 117 <dl class="listing"> 134 {% if collection.a_informer %}<dt>a informer</dt><dd>{{ collection.a_informer }}</dd>{% endif %} 135 {% if collection.acquisition_mode %}<dt>acquisition mode</dt><dd>{{ collection.acquisition_mode }}</dd>{% endif %} 136 {% if collection.champ36 %}<dt>champ36</dt><dd>{{ collection.champ36 }}</dd>{% endif %} 137 {% if collection.collector %}<dt>collector</dt><dd>{{ collection.collector }}</dd>{% endif %} 138 {% if collection.comment %}<dt>comment</dt><dd>{{ collection.comment }}</dd>{% endif %} 139 <!-- 140 <dt>compil face plage</dt><dd>{{ object.compil_face_plage }}</dd> 141 --> 142 {% if collection.deposant_cnrs %}<dt>deposant cnrs</dt><dd>{{ collection.deposant_cnrs }}</dd>{% endif %} 143 {% if collection.fiches %}<dt>fiches</dt><dd>{{ collection.fiches }}</dd>{% endif %} 144 {% if collection.is_full_copy %}<dt>is full copy</dt><dd>{{ collection.is_full_copy }}</dd>{% endif %} 145 {% if collection.is_original %}<dt>is original</dt><dd>{{ collection.is_original }}</dd>{% endif %} 146 {% if collection.numerisation %}<dt>numerisation</dt><dd>{{ collection.numerisation }}</dd>{% endif %} 147 {% if collection.physical_items_num %}<dt>physical items num</dt><dd>{{ collection.physical_items_num }}</dd>{% endif %} 148 {% if collection.publisher_collection %}<dt>publisher collection</dt><dd>{{ collection.publisher_collection }}</dd>{% endif %} 149 {% if collection.publisher_serial_id %}<dt>publisher serial id</dt><dd>{{ collection.publisher_serial_id }}</dd>{% endif %} 150 {% if collection.record_author %}<dt>record author</dt><dd>{{ collection.record_author }}</dd>{% endif %} 151 {% if collection.record_writer %}<dt>record writer</dt><dd>{{ collection.record_writer }}</dd>{% endif %} 152 {% if collection.ref_biblio %}<dt>ref biblio</dt><dd>{{ collection.ref_biblio }}</dd>{% endif %} 153 {% if collection.rights %}<dt>rights</dt><dd>{{ collection.rights }}</dd>{% endif %} 154 {% if collection.travail %}<dt>travail</dt><dd>{{ collection.travail }}</dd>{% endif %} 155 {% if collection.tri_dibm %}<dt>tri dibm</dt><dd>{{ collection.tri_dibm }}</dd>{% endif %} 118 {% dl_field collection.code %} 119 {% dl_field collection.old_code %} 120 <dt>{% trans "Media type" %}</dt><dd>{% trans "Audio" %}</dd> 121 {% dl_field collection.approx_duration %} 122 {% dl_field collection.computed_duration %} 123 {% dl_field collection.physical_items_num %} 124 <dt>{% trans "Number of items" %}</dt><dd>{{ collection.items.count }}</dd> 125 {% dl_field collection.physical_format %} 126 {% dl_field collection.ad_conversion %} 156 127 </dl> 157 128 </div> 158 129 </div> 159 {% endblock document_data %}130 {% endblock technical_data %} 160 131 </div> 161 132 <h4>Items</h4> 133 {% with collection.items.all as items %} 134 {% include "telemeta/inc/mediaitem_list.html" %} 135 {% endwith %} 136 <!-- 162 137 {% with collection.ordered_items as items %} 163 138 {% include "telemeta/inc/mediaitem_list.html" %} 164 139 {% endwith %} 140 --> 165 141 </div> 166 142 </div> -
trunk/telemeta/templatetags/telemeta_utils.py
r509 r512 4 4 from django.core.urlresolvers import reverse 5 5 import telemeta.models.dublincore as dc 6 from django.utils import html 7 from django import template 8 from django.utils.text import capfirst 6 9 7 10 register = template.Library() … … 94 97 else: 95 98 return dc.express_collection(resource) 99 100 class DescriptionListFieldNode(template.Node): 101 def __init__(self, variable, join_with = None): 102 cut = variable.split('.') 103 self.model = template.Variable('.'.join(cut[:-1])) 104 self.member = cut[-1] 105 self.join_with = join_with 106 107 def render(self, context): 108 try: 109 model = self.model.resolve(context) 110 label = html.escape(capfirst(unicode(model.field_label(self.member)))) 111 try: 112 value = getattr(model, self.member) 113 except AttributeError: 114 value = '<ERROR: no such field>' 115 except template.VariableDoesNotExist: 116 label = unicode(self.model) + '.' + self.member 117 value = '<ERROR: can\'t find variable>' 118 119 try: 120 value = value() 121 except TypeError: 122 pass 123 if self.join_with: 124 value = self.join_with.join([unicode(v) for v in value]) 125 if value: 126 value = html.escape(unicode(value)) 127 markup = '<dt>%s</dt><dd>%s</dd>' % (label, value) 128 return markup 129 130 return '' 131 132 @register.tag 133 def dl_field(parser, token): 134 cut = token.split_contents() 135 join_with = None 136 try: 137 tag_name, variable = cut 138 except ValueError: 139 try: 140 tag_name, variable, arg3, arg4, arg5 = cut 141 if arg3 == 'join' and arg4 == 'with'and arg5[0] == arg5[-1] and arg5[0] in ('"', "'"): 142 join_with = arg5[1:-1] 143 else: 144 raise ValueError() 145 except ValueError: 146 raise template.TemplateSyntaxError("%r tag: invalid arguments" 147 % token.contents.split()[0]) 148 149 return DescriptionListFieldNode(variable, join_with=join_with) 150 151 @register.filter 152 def prepend(str, prefix): 153 if str: 154 return prefix + unicode(str) 155 return ''
