From b4a28f5034df8a8b3a446e486ab2812d9ad146b8 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 16 Feb 2018 23:16:02 -0800 Subject: [PATCH] Make Photo.bytestring a @property. This is the kind of thing that should be a @property, because it's very low processing power and doesn't hit the database. --- etiquette/jsonify.py | 2 +- etiquette/objects.py | 1 + frontends/etiquette_flask/templates/photo.html | 2 +- frontends/etiquette_flask/templates/photo_card.html | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/etiquette/jsonify.py b/etiquette/jsonify.py index ec36447..9046622 100644 --- a/etiquette/jsonify.py +++ b/etiquette/jsonify.py @@ -48,7 +48,7 @@ def photo(p, include_albums=True, include_tags=True): 'bytes': p.bytes, 'duration_str': p.duration_string, 'duration': p.duration, - 'bytes_str': p.bytestring(), + 'bytes_str': p.bytestring, 'has_thumbnail': bool(p.thumbnail), 'created': p.created, 'filename': p.basename, diff --git a/etiquette/objects.py b/etiquette/objects.py index 4adeb22..fc4ff31 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -635,6 +635,7 @@ class Photo(ObjectBase): self.photodb.commit() return tag + @property def bytestring(self): if self.bytes is not None: return bytestring.bytestring(self.bytes) diff --git a/frontends/etiquette_flask/templates/photo.html b/frontends/etiquette_flask/templates/photo.html index 4163ec7..cba4e54 100644 --- a/frontends/etiquette_flask/templates/photo.html +++ b/frontends/etiquette_flask/templates/photo.html @@ -192,7 +192,7 @@
  • Dimensions: {{photo.width}}x{{photo.height}} px
  • Aspect ratio: {{photo.ratio}}
  • {% endif %} -
  • Size: {{photo.bytestring()}}
  • +
  • Size: {{photo.bytestring}}
  • {% if photo.duration %}
  • Duration: {{photo.duration_string}}
  • Overall Bitrate: {{photo.bitrate|int}} kbps
  • diff --git a/frontends/etiquette_flask/templates/photo_card.html b/frontends/etiquette_flask/templates/photo_card.html index 39581ba..8292fea 100644 --- a/frontends/etiquette_flask/templates/photo_card.html +++ b/frontends/etiquette_flask/templates/photo_card.html @@ -20,7 +20,7 @@
    {{photo.basename}} - +
    {% else %} @@ -69,7 +69,7 @@ {{- metadata_inner|safe -}} - {{photo.bytestring()}} + {{photo.bytestring}}