Making the API make use of the new submit tooling.
This commit sponsored by Zakkai Kauffman-Rogoff. Thanks! :)
This commit is contained in:
@@ -23,7 +23,7 @@ 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
|
||||
from mediagoblin.db.models import MediaEntry, ProcessingMetaData
|
||||
from mediagoblin.processing import mark_entry_failed
|
||||
from mediagoblin.processing.task import ProcessMedia
|
||||
from mediagoblin.notifications import add_comment_subscription
|
||||
@@ -100,8 +100,9 @@ def submit_media(mg_app, user, submitted_file, filename,
|
||||
title=None, description=None,
|
||||
license=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):
|
||||
urlgen=None,):
|
||||
"""
|
||||
Args:
|
||||
- mg_app: The MediaGoblinApp instantiated for this process
|
||||
@@ -118,6 +119,7 @@ def submit_media(mg_app, user, submitted_file, filename,
|
||||
with this entry
|
||||
- upload_limit: size in megabytes that's the per-user upload limit
|
||||
- max_file_size: maximum size each file can be that's uploaded
|
||||
- callback_url: possible post-hook to call after submission
|
||||
- urlgen: if provided, used to do the feed_url update
|
||||
"""
|
||||
if upload_limit and user.uploaded >= upload_limit:
|
||||
@@ -172,6 +174,14 @@ def submit_media(mg_app, user, submitted_file, filename,
|
||||
# Save now so we have this data before kicking off processing
|
||||
entry.save()
|
||||
|
||||
# Various "submit to stuff" things, callbackurl and this silly urlgen
|
||||
# thing
|
||||
if callback_url:
|
||||
metadata = ProcessingMetaData()
|
||||
metadata.media_entry = entry
|
||||
metadata.callback_url = callback_url
|
||||
metadata.save()
|
||||
|
||||
if urlgen:
|
||||
feed_url = urlgen(
|
||||
'mediagoblin.user_pages.atom_feed',
|
||||
|
||||
Reference in New Issue
Block a user