Add collection option to 'addmedia' cli uploading
This commit is contained in:
parent
e99431cc05
commit
a3c480248f
@ -31,6 +31,7 @@ Here's a longer example that makes use of more options::
|
||||
./bin/gmg addmedia aveyah awesome_spaceship.png \
|
||||
--title "My awesome spaceship" \
|
||||
--description "Flying my awesome spaceship, since I'm an awesome pilot" \
|
||||
--collection-slug i-m-an-awesome-pilot \
|
||||
--license "http://creativecommons.org/licenses/by-sa/3.0/" \
|
||||
--tags "spaceships, pilots, awesome" \
|
||||
--slug "awesome-spaceship"
|
||||
|
@ -51,6 +51,11 @@ def parser_setup(subparser):
|
||||
help=(
|
||||
"Slug for this media entry. "
|
||||
"Will be autogenerated if unspecified."))
|
||||
subparser.add_argument(
|
||||
"-c", "--collection-slug",
|
||||
help=(
|
||||
"Slug of the collection for this media entry."
|
||||
"Should already exits."))
|
||||
|
||||
subparser.add_argument(
|
||||
'--celery',
|
||||
@ -94,6 +99,7 @@ def addmedia(args):
|
||||
submitted_file=file(abs_filename, 'r'), filename=filename,
|
||||
title=maybe_unicodeify(args.title),
|
||||
description=maybe_unicodeify(args.description),
|
||||
collection_slug=args.collection_slug,
|
||||
license=maybe_unicodeify(args.license),
|
||||
tags_string=maybe_unicodeify(args.tags) or u"",
|
||||
upload_limit=upload_limit, max_file_size=max_file_size)
|
||||
|
@ -23,11 +23,12 @@ from werkzeug.datastructures import FileStorage
|
||||
|
||||
from mediagoblin import mg_globals
|
||||
from mediagoblin.tools.text import convert_to_tag_list_of_dicts
|
||||
from mediagoblin.db.models import MediaEntry, ProcessingMetaData
|
||||
from mediagoblin.db.models import Collection, MediaEntry, ProcessingMetaData
|
||||
from mediagoblin.processing import mark_entry_failed
|
||||
from mediagoblin.processing.task import ProcessMedia
|
||||
from mediagoblin.notifications import add_comment_subscription
|
||||
from mediagoblin.media_types import sniff_media
|
||||
from mediagoblin.user_pages.lib import add_media_to_collection
|
||||
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
@ -97,7 +98,7 @@ class UserPastUploadLimit(UploadLimitError):
|
||||
|
||||
|
||||
def submit_media(mg_app, user, submitted_file, filename,
|
||||
title=None, description=None,
|
||||
title=None, description=None, collection_slug=None,
|
||||
license=None, metadata=None, tags_string=u"",
|
||||
upload_limit=None, max_file_size=None,
|
||||
callback_url=None,
|
||||
@ -114,6 +115,7 @@ def submit_media(mg_app, user, submitted_file, filename,
|
||||
one on disk being referenced by submitted_file.
|
||||
- title: title for this media entry
|
||||
- description: description for this media entry
|
||||
- collection_slug: collection for this media entry
|
||||
- license: license for this media entry
|
||||
- tags_string: comma separated string of tags to be associated
|
||||
with this entry
|
||||
@ -191,6 +193,11 @@ def submit_media(mg_app, user, submitted_file, filename,
|
||||
else:
|
||||
feed_url = None
|
||||
|
||||
# add to collection
|
||||
if collection_slug:
|
||||
collection = Collection.query.filter_by(slug=collection_slug).first()
|
||||
add_media_to_collection(collection, entry)
|
||||
|
||||
# Pass off to processing
|
||||
#
|
||||
# (... don't change entry after this point to avoid race
|
||||
|
Loading…
x
Reference in New Issue
Block a user