Merge remote-tracking branch 'spechards-mediagoblin/master'
authorBoris Bobrov <breton@cynicmansion.ru>
Sun, 29 Jan 2017 16:09:06 +0000 (19:09 +0300)
committerBoris Bobrov <breton@cynicmansion.ru>
Sun, 29 Jan 2017 16:09:06 +0000 (19:09 +0300)
Conflicts:
mediagoblin/submit/lib.py -- happened because of creator->actor
                                     change

Fixes issue #915

1  2 
docs/source/siteadmin/commandline-upload.rst
mediagoblin/gmg_commands/addmedia.py
mediagoblin/submit/lib.py

index 9685d5a5c80fce47c3e2f13ae08f169effb6dea7,2f0957603f848337a5efed2679367c2bfbeae849..babc6ed75a50df6fe7cebe1b7f20b3c9eef1cbfb
@@@ -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.")
index 4979def85c5956619556e9b366d1d4bea0520b4d,d54591d6fb312c7b1e17a5eb5ac98b3e975865bb..08a603e9aa317cc9b41e25156db9967a2aa4a07a
@@@ -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.db.models import MediaEntry, ProcessingMetaData
 +from mediagoblin.tools.federation import create_activity, create_generator
+ 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
      else:
          feed_url = None
  
 -        collection = Collection.query.filter_by(slug=collection_slug, creator=user.id).first()
 +    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,
++                                                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