From: Elrond Date: Fri, 23 Mar 2012 19:16:42 +0000 (+0100) Subject: Create MediaEntry.exif_display_iter() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5bad26bc47201aea14b57b0e03aca7eb89447212;p=mediagoblin.git Create MediaEntry.exif_display_iter() MediaEntry.media_data.exif_all will contain all the "clean" EXIF data. MediaEntry.exif_display_iter() is an iterator that fetches the most interesting entries for display from that data. --- diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index 4f9e1b11..7d0e0e9a 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -32,6 +32,7 @@ from mediagoblin.auth import lib as auth_lib from mediagoblin.tools import common, licenses from mediagoblin.tools.text import cleaned_markdown_conversion from mediagoblin.tools.url import slugify +from mediagoblin.tools.exif import USEFUL_TAGS class UserMixin(object): @@ -123,6 +124,15 @@ class MediaEntryMixin(object): """Return license dict for requested license""" return licenses.SUPPORTED_LICENSES[self.license or ""] + def exif_display_iter(self): + if not self.media_data: + return + exif_all = self.media_data.get("exif_all") + + for key in USEFUL_TAGS: + if key in exif_all: + yield key, exif_all[key] + class MediaCommentMixin(object): @property