Changeset 5bf08b0


Ignore:
Timestamp:
02/11/10 17:44:17 (4 years ago)
Author:
olivier <>
Branches:
master, crem, crem2, dev, dev2, diadems, feature/breadcrumbs, feature/ts-0.5, feature/ts-0.5.4, feature/writecache, forma, generic, instru_search, lam, lam2, mapsv3, merge, nlivemulti, production, release/1.4.4, sabiod, security, server, social, storage, telecaster, test, video
Children:
97f48ec
Parents:
96ab603
git-author:
olivier <> (02/11/10 17:44:17)
git-committer:
olivier <> (02/11/10 17:44:17)
Message:

various fixes related to new models and Django compatibility

Location:
telemeta
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • telemeta/models/core.py

    r96ab603 r5bf08b0  
    299299        super(DateTimeField, self).__init__(*args, **normalize_field(kwargs, '0000-00-00 00:00')) 
    300300 
     301    def get_db_prep_value(self, value): 
     302        if value is None and not self.null:  
     303            return '0000-00-00 00:00' 
     304 
     305        return super(DateTimeField, self).get_db_prep_value(value) 
     306 
    301307class FileField(models.FileField): 
    302308    """FileField normalized with normalize_field()""" 
     
    316322    def __init__(self, *args, **kwargs): 
    317323        super(DateField, self).__init__(*args, **normalize_field(kwargs, '0000-00-00')) 
     324 
     325    def get_db_prep_value(self, value): 
     326        if value is None and not self.null:  
     327            return '0000-00-00' 
     328 
     329        return super(DateField, self).get_db_prep_value(value) 
    318330 
    319331class RequiredFieldError(Exception): 
  • telemeta/models/media.py

    r96ab603 r5bf08b0  
    224224    ethnic_group          = WeakForeignKey('EthnicGroup', related_name="items",  
    225225                                           verbose_name=_('population / social group')) 
    226     title                 = CharField(_('title'), required=True) 
     226    title                 = CharField(_('title')) 
    227227    alt_title             = CharField(_('original title / translation')) 
    228228    author                = CharField(_('author')) 
     
    275275 
    276276    def save(self, force_insert=False, force_update=False): 
    277         if not self.code: 
    278             raise RequiredFieldError(self, self._meta.get_field('code')) 
    279         if not self.is_valid_code(self.code): 
     277        if self.code and not self.is_valid_code(self.code): 
    280278            raise MediaInvalidCodeError("%s is not a valid item code for collection %s"  
    281279                                        % (self.code, self.collection.code)) 
  • telemeta/templates/telemeta_default/collection_xspf.xml

    r792cd0d r5bf08b0  
    1111 
    1212{% block tracklist %} 
    13 {% for item in collection.ordered_items %} 
     13{% for item in collection.items.all %} 
    1414    <track> 
    1515      <title>{{ item }}</title> 
    1616      <meta rel="type">mp3</meta> 
    1717      <location>http://{{ host }}{% url telemeta-item-export item.public_id,"mp3" %}</location> 
    18       <duration>{{ item.get_duration|mul:1000 }}</duration> 
     18      <duration>{{ item.computed_duration.as_seconds|mul:1000 }}</duration> 
    1919      <info>http://{{ host }}{% url telemeta-item-detail item.public_id %}</info> 
    2020    </track> 
  • telemeta/templates/telemeta_default/inc/collection_list.html

    red3547b r5bf08b0  
    2727    {% if collection.recorded_from_year %} 
    2828        {{ collection.recorded_from_year }} 
    29         {% if collection.recorded_to_year and collection.recorded_to_year != collection.recorded_from_year %} 
     29        {% if collection.recorded_to_year and not collection.recorded_to_year|equals:collection.recorded_from_year %} 
    3030            - {{ collection.recorded_to_year }} 
    3131        {% endif %} 
  • telemeta/templates/telemeta_default/mediaitem_detail.html

    red3547b r5bf08b0  
    2121soundManager.debugMode = false; 
    2222set_player_image_url('{% url telemeta-item-visualize item.public_id,visualizer_id,"WIDTH","HEIGHT" %}'); 
    23 load_player({{ item.get_duration }}); 
     23load_player({{ item.computed_duration.as_seconds }}); 
    2424</script> 
    2525 
  • telemeta/web/base.py

    rc1a2c1c r5bf08b0  
    4747import telemeta 
    4848from telemeta.models import MediaItem, Location, MediaCollection 
     49from telemeta.models import dublincore 
    4950from telemeta.core import Component, ExtensionPoint 
    5051from telemeta.export import * 
     
    154155 
    155156        infile = item.file.path 
    156         metadata = item.to_dublincore().flatten() 
     157        metadata = dublincore.express_item(item).flatten() 
    157158        stream = exporter.process(item.id, infile, metadata) 
    158159 
Note: See TracChangeset for help on using the changeset viewer.