From: Elrond Date: Thu, 15 Mar 2012 11:35:58 +0000 (+0100) Subject: Fix media display for no media_data row in sql. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=729424befd80ed34d486cf995499ce7a8bd0806f;p=mediagoblin.git Fix media display for no media_data row in sql. If there is no media_data row for the current media (for whatever reason, there might be good ones), let MediaEntry.media_data not raise an exception but just return None. The exif display part now handles this by checking whether .media_data.exif is defined (None has no attribute exif, so it's undefined, all fine). --- diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py index 394c35a3..a2feeebb 100644 --- a/mediagoblin/db/sql/models.py +++ b/mediagoblin/db/sql/models.py @@ -176,7 +176,7 @@ class MediaEntry(Base, MediaEntryMixin): session = Session() return session.query(self.media_data_table).filter_by( - media_entry=self.id).one() + media_entry=self.id).first() def media_data_init(self, **kwargs): """ diff --git a/mediagoblin/templates/mediagoblin/utils/exif.html b/mediagoblin/templates/mediagoblin/utils/exif.html index bd2e3307..3c1f4ceb 100644 --- a/mediagoblin/templates/mediagoblin/utils/exif.html +++ b/mediagoblin/templates/mediagoblin/utils/exif.html @@ -17,8 +17,8 @@ #} {% block exif_content %} - {% if media.media_data.has_key('exif') - and app_config['exif_visible'] + {% if app_config['exif_visible'] + and media.media_data.exif is defined and media.media_data.exif.has_key('useful') %}

EXIF