From 228c4470f40d66e8b9383321d44d89e2a1c0ecad Mon Sep 17 00:00:00 2001 From: Elrond Date: Wed, 4 Jan 2012 11:57:08 +0100 Subject: [PATCH] Dot-Notation for MediaEntry.media_files --- mediagoblin/gmg_commands/import_export.py | 4 ++-- mediagoblin/media_types/video/processing.py | 6 +++--- mediagoblin/templates/mediagoblin/edit/attachments.html | 2 +- mediagoblin/templates/mediagoblin/edit/edit.html | 2 +- mediagoblin/templates/mediagoblin/media_displays/ascii.html | 4 ++-- mediagoblin/templates/mediagoblin/media_displays/video.html | 4 ++-- mediagoblin/templates/mediagoblin/user_pages/media.html | 4 ++-- .../mediagoblin/user_pages/media_confirm_delete.html | 2 +- mediagoblin/templates/mediagoblin/utils/object_gallery.html | 2 +- mediagoblin/tools/files.py | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mediagoblin/gmg_commands/import_export.py b/mediagoblin/gmg_commands/import_export.py index eda41f4c..7f699429 100644 --- a/mediagoblin/gmg_commands/import_export.py +++ b/mediagoblin/gmg_commands/import_export.py @@ -65,7 +65,7 @@ def _import_media(db, args): args._cache_path['queue']) for entry in db.MediaEntry.find(): - for name, path in entry['media_files'].items(): + for name, path in entry.media_files.items(): _log.info('Importing: {0} - {1}'.format( entry.title, name)) @@ -207,7 +207,7 @@ def _export_media(db, args): args._cache_path['queue']) for entry in db.MediaEntry.find(): - for name, path in entry['media_files'].items(): + for name, path in entry.media_files.items(): _log.info(u'Exporting {0} - {1}'.format( entry.title, name)) diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py index 7d261226..c260cfd6 100644 --- a/mediagoblin/media_types/video/processing.py +++ b/mediagoblin/media_types/video/processing.py @@ -74,7 +74,7 @@ def process_video(entry): tmp_dst.read()) _log.debug('Saved medium') - entry['media_files']['webm_640'] = medium_filepath + entry.media_files['webm_640'] = medium_filepath # Save the width and height of the transcoded video entry.media_data['video'] = { @@ -94,7 +94,7 @@ def process_video(entry): tmp_thumb.read()) _log.debug('Saved thumbnail') - entry['media_files']['thumb'] = thumbnail_filepath + entry.media_files['thumb'] = thumbnail_filepath if video_config['keep_original']: # Push original file to public storage @@ -111,7 +111,7 @@ def process_video(entry): original_file.write(queued_file.read()) _log.debug('Saved original') - entry['media_files']['original'] = original_filepath + entry.media_files['original'] = original_filepath mgg.queue_store.delete_file(queued_filepath) diff --git a/mediagoblin/templates/mediagoblin/edit/attachments.html b/mediagoblin/templates/mediagoblin/edit/attachments.html index 124d0313..06062cd3 100644 --- a/mediagoblin/templates/mediagoblin/edit/attachments.html +++ b/mediagoblin/templates/mediagoblin/edit/attachments.html @@ -27,7 +27,7 @@

Editing attachments for {{ media.title }}

+ media.media_files['thumb']) }}" />
{% if media.attachment_files|count %} diff --git a/mediagoblin/templates/mediagoblin/edit/edit.html b/mediagoblin/templates/mediagoblin/edit/edit.html index 2dfaddc8..024a2b4d 100644 --- a/mediagoblin/templates/mediagoblin/edit/edit.html +++ b/mediagoblin/templates/mediagoblin/edit/edit.html @@ -29,7 +29,7 @@

{% trans media_title=media.title %}Editing {{ media_title }}{% endtrans %}

+ media.media_files['thumb']) }}" />
{{ wtforms_util.render_divs(form) }}
diff --git a/mediagoblin/templates/mediagoblin/media_displays/ascii.html b/mediagoblin/templates/mediagoblin/media_displays/ascii.html index 9e77066a..6b40bf08 100644 --- a/mediagoblin/templates/mediagoblin/media_displays/ascii.html +++ b/mediagoblin/templates/mediagoblin/media_displays/ascii.html @@ -23,14 +23,14 @@
       {%- autoescape False -%}
       {{- request.app.public_store.get_file(
-             media['media_files']['unicode']).read()|string -}}
+             media.media_files['unicode']).read()|string -}}
       {%- endautoescape -%}
     
{% if 'original' in media.media_files %}

+ media.media_files['original']) }}"> {%- trans -%} Original {%- endtrans -%} diff --git a/mediagoblin/templates/mediagoblin/media_displays/video.html b/mediagoblin/templates/mediagoblin/media_displays/video.html index fc08f963..6b5e7a0e 100644 --- a/mediagoblin/templates/mediagoblin/media_displays/video.html +++ b/mediagoblin/templates/mediagoblin/media_displays/video.html @@ -27,7 +27,7 @@ preload="auto" data-setup="">

{%- trans -%}Sorry, this video will not work because @@ -42,7 +42,7 @@ {% if 'original' in media.media_files %}

+ media.media_files['original']) }}"> {%- trans -%} Original {%- endtrans -%} diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index ca650f63..d52f544f 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -36,9 +36,9 @@ {# if there's a medium file size, that means the medium size # isn't the original... so link to the original! #} - {% if media['media_files'].has_key('medium') %} + {% if media.media_files.has_key('medium') %} + media.media_files['original']) }}"> Image for {{ media.title }} diff --git a/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html b/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html index 6c483769..408bca05 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html @@ -34,7 +34,7 @@

+ media.media_files['thumb']) }}" />

diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html index b8155f03..5f628dc7 100644 --- a/mediagoblin/templates/mediagoblin/utils/object_gallery.html +++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html @@ -31,7 +31,7 @@ {%- elif loop.last %} thumb_entry_last{% endif %}">
+ entry.media_files['thumb']) }}" /> {% if entry.title %}
diff --git a/mediagoblin/tools/files.py b/mediagoblin/tools/files.py index e0bf0569..10f1d994 100644 --- a/mediagoblin/tools/files.py +++ b/mediagoblin/tools/files.py @@ -23,7 +23,7 @@ def delete_media_files(media): Arguments: - media: A MediaEntry document """ - for listpath in media['media_files'].itervalues(): + for listpath in media.media_files.itervalues(): mg_globals.public_store.delete_file( listpath) -- 2.25.1