Changeset 12d665f


Ignore:
Timestamp:
11/02/2010 14:03:12 (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:
96ab603
Parents:
c1a2c1c
git-author:
olivier <> (11/02/2010 14:03:12)
git-committer:
olivier <> (11/02/2010 14:03:12)
Message:

store durations as integers for compatibility with Django mysql backend

File:
1 edited

Legend:

Unmodified
Added
Removed
  • telemeta/models/core.py

    r622588f r12d665f  
    145145 
    146146    default_error_messages = { 
    147         'invalid': _('Enter a valid duration in HH:MM[:ss[.uuuuuu]] format.'), 
     147        'invalid': _('Enter a valid duration in HH:MM[:ss] format.'), 
    148148    } 
    149149 
     
    151151        super(DurationField, self).__init__(*args, **normalize_field(kwargs, '00:00')) 
    152152 
    153     def get_internal_type(self): 
    154         return 'TimeField' 
     153    def db_type(self): 
     154        return 'int' 
    155155 
    156156    def to_python(self, value): 
    157157        if value is None: 
    158158            return None 
     159        if isinstance(value, int) or isinstance(value, long): 
     160            return Duration(seconds=value) 
    159161        if isinstance(value, datetime.time): 
    160162            return Duration(hours=value.hour, minutes=value.minute, seconds=value.second) 
     
    175177    def get_db_prep_value(self, value, connection, prepared=False): 
    176178        # Casts times into the format expected by the backend 
    177         return unicode(value) 
     179        return value.as_seconds() 
    178180 
    179181    def value_to_string(self, obj): 
Note: See TracChangeset for help on using the changeset viewer.