Refactor submit util new_upload_entry

This tool creates an initial media entry for a given user.
No magic. It just prefills the license with the user's
default license and adds the user as uploader.
This commit is contained in:
Elrond
2013-05-21 00:28:37 +02:00
parent 4adc3a85dd
commit 6c1467d570
4 changed files with 17 additions and 14 deletions

View File

@@ -27,7 +27,7 @@ from mediagoblin.media_types import sniff_media
from mediagoblin.plugins.api.tools import api_auth, get_entry_serializable, \
json_response
from mediagoblin.submit.lib import check_file_field, prepare_queue_task, \
run_process_media
run_process_media, new_upload_entry
_log = logging.getLogger(__name__)
@@ -53,7 +53,7 @@ def post_entry(request):
media_type, media_manager = sniff_media(media_file)
entry = request.db.MediaEntry()
entry = new_upload_entry(request.user)
entry.media_type = unicode(media_type)
entry.title = unicode(request.form.get('title')
or splitext(media_file.filename)[0])
@@ -61,8 +61,6 @@ def post_entry(request):
entry.description = unicode(request.form.get('description'))
entry.license = unicode(request.form.get('license', ''))
entry.uploader = request.user.id
entry.generate_slug()
# queue appropriately