Ticket #5532: issue_5532.patch

File issue_5532.patch, 3.0 KB (added by simenheg, 7 years ago)
  • docs/source/siteadmin/commandline-upload.rst

    From 48145f82486305fba7fd667aef865166a644e2f3 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
    Date: Sun, 8 Oct 2017 18:19:08 +0200
    Subject: [PATCH] Handle collection in batchaddmedia command
    
    Make the batchaddmedia command look for a 'collection-slug' column, that
    for each row may specify the slug of a collection that the media should
    be added to. This matches the '--collection-slug' argument of the
    addmedia command.
    ---
     docs/source/siteadmin/commandline-upload.rst | 1 +
     mediagoblin/gmg_commands/batchaddmedia.py    | 7 +++----
     2 files changed, 4 insertions(+), 4 deletions(-)
    
    diff --git a/docs/source/siteadmin/commandline-upload.rst b/docs/source/siteadmin/commandline-upload.rst
    index ef597a44..086854ce 100644
    a b just as easy to provide this information through the correct metadata columns.  
    8787- **license** is used to set a license for your piece a media for MediaGoblin's use. This must be a URI.
    8888- **title** will set the title displayed to MediaGoblin users.
    8989- **description** will set a description of your media.
     90- **collection-slug** will add the media to a collection, if a collection with the given slug exists.
    9091
    9192Metadata columns
    9293----------------
  • mediagoblin/gmg_commands/batchaddmedia.py

    diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py
    index 274d72bc..a521fe4d 100644
    a b from six.moves.urllib.parse import urlparse  
    2828from mediagoblin.db.models import LocalUser
    2929from mediagoblin.gmg_commands import util as commands_util
    3030from mediagoblin.submit.lib import (
    31     submit_media, get_upload_file_limits,
    32     FileUploadLimit, UserUploadLimit, UserPastUploadLimit)
     31    submit_media, FileUploadLimit, UserUploadLimit, UserPastUploadLimit)
    3332from mediagoblin.tools.metadata import compact_and_validate
    3433from mediagoblin.tools.translate import pass_to_ugettext as _
    3534from jsonschema.exceptions import ValidationError
    def batchaddmedia(args):  
    7372                    username=args.username)))
    7473        return
    7574
    76     temp_files = []
    77 
    7875    if os.path.isfile(args.metadata_path):
    7976        metadata_path = args.metadata_path
    8077
    def batchaddmedia(args):  
    113110        title = file_metadata.get('title') or file_metadata.get('dc:title')
    114111        description = (file_metadata.get('description') or
    115112            file_metadata.get('dc:description'))
     113        collection_slug = file_metadata.get('collection-slug')
    116114
    117115        license = file_metadata.get('license')
    118116        try:
    FAIL: Local file {filename} could not be accessed.  
    155153                filename=filename,
    156154                title=maybe_unicodeify(title),
    157155                description=maybe_unicodeify(description),
     156                collection_slug=maybe_unicodeify(collection_slug),
    158157                license=maybe_unicodeify(license),
    159158                metadata=json_ld_metadata,
    160159                tags_string=u"")