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.
|
87 | 87 | - **license** is used to set a license for your piece a media for MediaGoblin's use. This must be a URI. |
88 | 88 | - **title** will set the title displayed to MediaGoblin users. |
89 | 89 | - **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. |
90 | 91 | |
91 | 92 | Metadata columns |
92 | 93 | ---------------- |
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
|
28 | 28 | from mediagoblin.db.models import LocalUser |
29 | 29 | from mediagoblin.gmg_commands import util as commands_util |
30 | 30 | from mediagoblin.submit.lib import ( |
31 | | submit_media, get_upload_file_limits, |
32 | | FileUploadLimit, UserUploadLimit, UserPastUploadLimit) |
| 31 | submit_media, FileUploadLimit, UserUploadLimit, UserPastUploadLimit) |
33 | 32 | from mediagoblin.tools.metadata import compact_and_validate |
34 | 33 | from mediagoblin.tools.translate import pass_to_ugettext as _ |
35 | 34 | from jsonschema.exceptions import ValidationError |
… |
… |
def batchaddmedia(args):
|
73 | 72 | username=args.username))) |
74 | 73 | return |
75 | 74 | |
76 | | temp_files = [] |
77 | | |
78 | 75 | if os.path.isfile(args.metadata_path): |
79 | 76 | metadata_path = args.metadata_path |
80 | 77 | |
… |
… |
def batchaddmedia(args):
|
113 | 110 | title = file_metadata.get('title') or file_metadata.get('dc:title') |
114 | 111 | description = (file_metadata.get('description') or |
115 | 112 | file_metadata.get('dc:description')) |
| 113 | collection_slug = file_metadata.get('collection-slug') |
116 | 114 | |
117 | 115 | license = file_metadata.get('license') |
118 | 116 | try: |
… |
… |
FAIL: Local file {filename} could not be accessed.
|
155 | 153 | filename=filename, |
156 | 154 | title=maybe_unicodeify(title), |
157 | 155 | description=maybe_unicodeify(description), |
| 156 | collection_slug=maybe_unicodeify(collection_slug), |
158 | 157 | license=maybe_unicodeify(license), |
159 | 158 | metadata=json_ld_metadata, |
160 | 159 | tags_string=u"") |