From: Boris Bobrov Date: Sun, 29 Jan 2017 16:09:06 +0000 (+0300) Subject: Merge remote-tracking branch 'spechards-mediagoblin/master' X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f86dafe2a01e64183e54d4a98eccb01d007c68e6;p=mediagoblin.git Merge remote-tracking branch 'spechards-mediagoblin/master' Conflicts: mediagoblin/submit/lib.py -- happened because of creator->actor change Fixes issue #915 --- f86dafe2a01e64183e54d4a98eccb01d007c68e6 diff --cc mediagoblin/gmg_commands/addmedia.py index 9685d5a5,2f095760..babc6ed7 --- a/mediagoblin/gmg_commands/addmedia.py +++ b/mediagoblin/gmg_commands/addmedia.py @@@ -97,14 -96,16 +102,15 @@@ def addmedia(args) submit_media( mg_app=app, user=user, - submitted_file=file(abs_filename, 'r'), filename=filename, + submitted_file=open(abs_filename, 'rb'), 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) + tags_string=maybe_unicodeify(args.tags) or u"") except FileUploadLimit: - print "This file is larger than the upload limits for this site." + print("This file is larger than the upload limits for this site.") except UserUploadLimit: - print "This file will put this user past their upload limits." + print("This file will put this user past their upload limits.") except UserPastUploadLimit: - print "This user is already past their upload limits." + print("This user is already past their upload limits.") diff --cc mediagoblin/submit/lib.py index 4979def8,d54591d6..08a603e9 --- a/mediagoblin/submit/lib.py +++ b/mediagoblin/submit/lib.py @@@ -24,10 -22,8 +24,10 @@@ from werkzeug.utils import secure_filen from werkzeug.datastructures import FileStorage from mediagoblin import mg_globals +from mediagoblin.tools.response import json_response from mediagoblin.tools.text import convert_to_tag_list_of_dicts +from mediagoblin.tools.federation import create_activity, create_generator - 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 @@@ -101,9 -98,12 +102,9 @@@ class UserPastUploadLimit(UploadLimitEr 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, - # If provided we'll do the feed_url update, otherwise ignore - urlgen=None,): + callback_url=None, urlgen=None,): """ Args: - mg_app: The MediaGoblinApp instantiated for this process @@@ -197,12 -193,12 +199,19 @@@ else: feed_url = None + add_comment_subscription(user, entry) + + # Create activity + create_activity("post", entry, entry.actor) + entry.save() + + # add to collection + if collection_slug: - collection = Collection.query.filter_by(slug=collection_slug, creator=user.id).first() ++ collection = Collection.query.filter_by(slug=collection_slug, ++ actor=user.id).first() + if collection: + add_media_to_collection(collection, entry) + # Pass off to processing # # (... don't change entry after this point to avoid race