Make photo.duration_string a @property

master
voussoir 2017-03-10 15:07:34 -08:00
parent d7cd1e9748
commit afe7085702
4 changed files with 4 additions and 3 deletions

View File

@ -33,7 +33,7 @@ def photo(p, include_albums=True, include_tags=True):
'ratio': p.ratio, 'ratio': p.ratio,
'area': p.area, 'area': p.area,
'bytes': p.bytes, 'bytes': p.bytes,
'duration_str': p.duration_string(), 'duration_str': p.duration_string,
'duration': p.duration, 'duration': p.duration,
'bytes_str': p.bytestring(), 'bytes_str': p.bytestring(),
'has_thumbnail': bool(p.thumbnail), 'has_thumbnail': bool(p.thumbnail),

View File

@ -505,6 +505,7 @@ class Photo(ObjectBase):
self.photodb.log.debug('Committing - delete photo') self.photodb.log.debug('Committing - delete photo')
self.photodb.commit() self.photodb.commit()
@property
def duration_string(self): def duration_string(self):
if self.duration is None: if self.duration is None:
return None return None

View File

@ -169,7 +169,7 @@
{% endif %} {% endif %}
<li>Size: {{photo.bytestring()}}</li> <li>Size: {{photo.bytestring()}}</li>
{% if photo.duration %} {% if photo.duration %}
<li>Duration: {{photo.duration_string()}}</li> <li>Duration: {{photo.duration_string}}</li>
{% endif %} {% endif %}
<li><a href="/file/{{photo.id}}{{photo.dot_extension}}?download=1">Download as {{photo.id}}.{{photo.extension}}</a></li> <li><a href="/file/{{photo.id}}{{photo.dot_extension}}?download=1">Download as {{photo.id}}.{{photo.extension}}</a></li>
<li><a href="/file/{{photo.id}}{{photo.dot_extension}}?download=1&original_filename=1">Download as "{{photo.basename}}"</a></li> <li><a href="/file/{{photo.id}}{{photo.dot_extension}}?download=1&original_filename=1">Download as "{{photo.basename}}"</a></li>

View File

@ -60,7 +60,7 @@
{{photo.width}}&times;{{photo.height}}, {{photo.width}}&times;{{photo.height}},
{% endif %} {% endif %}
{% if photo.duration %} {% if photo.duration %}
{{photo.duration_string()}}, {{photo.duration_string}},
{% endif %} {% endif %}
<a target="_blank" href="/file/{{photo.id}}.{{photo.extension}}">{{photo.bytestring()}}</a> <a target="_blank" href="/file/{{photo.id}}.{{photo.extension}}">{{photo.bytestring()}}</a>
</span> </span>