From 3eaee8bc02df1f09fc9accb76e988872e9a7f8e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
Date: Sun, 15 Oct 2017 13:33:36 +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 | 2 ++
2 files changed, 3 insertions(+)
diff --git a/docs/source/siteadmin/commandline-upload.rst b/docs/source/siteadmin/commandline-upload.rst
index 913e7e6c..756f5fa8 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..573942e5 100644
a
|
b
|
def batchaddmedia(args):
|
113 | 113 | title = file_metadata.get('title') or file_metadata.get('dc:title') |
114 | 114 | description = (file_metadata.get('description') or |
115 | 115 | file_metadata.get('dc:description')) |
| 116 | collection_slug = file_metadata.get('collection-slug') |
116 | 117 | |
117 | 118 | license = file_metadata.get('license') |
118 | 119 | try: |
… |
… |
FAIL: Local file {filename} could not be accessed.
|
155 | 156 | filename=filename, |
156 | 157 | title=maybe_unicodeify(title), |
157 | 158 | description=maybe_unicodeify(description), |
| 159 | collection_slug=maybe_unicodeify(collection_slug), |
158 | 160 | license=maybe_unicodeify(license), |
159 | 161 | metadata=json_ld_metadata, |
160 | 162 | tags_string=u"") |