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.")
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
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