From f84425c0c1ee0b8cd6bcf3dbab72551bf9a52e48 Mon Sep 17 00:00:00 2001 From: Elrond Date: Wed, 13 Mar 2013 22:38:28 +0100 Subject: [PATCH] Turning image's media manager into a new style class. images are the first media type to use the new style class based media manager. --- mediagoblin/media_types/image/__init__.py | 22 +++++++++++----------- mediagoblin/tests/test_submission.py | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mediagoblin/media_types/image/__init__.py b/mediagoblin/media_types/image/__init__.py index 3e167db1..15cc8dda 100644 --- a/mediagoblin/media_types/image/__init__.py +++ b/mediagoblin/media_types/image/__init__.py @@ -14,19 +14,19 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from mediagoblin.media_types import MediaManagerBase from mediagoblin.media_types.image.processing import process_image, \ sniff_handler -MEDIA_MANAGER = { - "human_readable": "Image", - "processor": process_image, # alternately a string, - # 'mediagoblin.media_types.image.processing'? - "sniff_handler": sniff_handler, - "display_template": "mediagoblin/media_displays/image.html", - "default_thumb": "images/media_thumbs/image.png", - "accepted_extensions": ["jpg", "jpeg", "png", "gif", "tiff"], +class ImageMediaManager(MediaManagerBase): + human_readable = "Image" + processor = staticmethod(process_image) + sniff_handler = staticmethod(sniff_handler) + display_template = "mediagoblin/media_displays/image.html" + default_thumb = "images/media_thumbs/image.png" + accepted_extensions = ["jpg", "jpeg", "png", "gif", "tiff"] + media_fetch_order = [u'medium', u'original', u'thumb'] + - # Used by the media_entry.get_display_media method - "media_fetch_order": [u'medium', u'original', u'thumb'], -} +MEDIA_MANAGER = ImageMediaManager diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py index 0d74848a..1430d062 100644 --- a/mediagoblin/tests/test_submission.py +++ b/mediagoblin/tests/test_submission.py @@ -231,7 +231,7 @@ class TestSubmission: media = self.check_media(request, {'title': u'Balanced Goblin'}, 1) assert media.media_type == u'mediagoblin.media_types.image' - assert media.media_manager.mm_dict == img_MEDIA_MANAGER + assert isinstance(media.media_manager, img_MEDIA_MANAGER) assert media.media_manager.entry == media -- 2.25.1