Fix #928 - cleanup to avoid duplicated get_upload_file_limits
Signed-off-by: Loic Dachary <loic@dachary.org>
This commit is contained in:
parent
d5421cc366
commit
6c0678576a
@ -85,8 +85,6 @@ def addmedia(args):
|
||||
print("Can't find a file with filename '%s'" % args.filename)
|
||||
return
|
||||
|
||||
upload_limit, max_file_size = get_upload_file_limits(user)
|
||||
|
||||
def maybe_unicodeify(some_string):
|
||||
# this is kinda terrible
|
||||
if some_string is None:
|
||||
@ -103,8 +101,7 @@ def addmedia(args):
|
||||
title=maybe_unicodeify(args.title),
|
||||
description=maybe_unicodeify(args.description),
|
||||
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.")
|
||||
except UserUploadLimit:
|
||||
|
@ -73,7 +73,6 @@ def batchaddmedia(args):
|
||||
username=args.username)))
|
||||
return
|
||||
|
||||
upload_limit, max_file_size = get_upload_file_limits(user)
|
||||
temp_files = []
|
||||
|
||||
if os.path.isfile(args.metadata_path):
|
||||
@ -87,7 +86,6 @@ def batchaddmedia(args):
|
||||
|
||||
abs_metadata_filename = os.path.abspath(metadata_path)
|
||||
abs_metadata_dir = os.path.dirname(abs_metadata_filename)
|
||||
upload_limit, max_file_size = get_upload_file_limits(user)
|
||||
|
||||
def maybe_unicodeify(some_string):
|
||||
# this is kinda terrible
|
||||
@ -159,8 +157,7 @@ FAIL: Local file {filename} could not be accessed.
|
||||
description=maybe_unicodeify(description),
|
||||
license=maybe_unicodeify(license),
|
||||
metadata=json_ld_metadata,
|
||||
tags_string=u"",
|
||||
upload_limit=upload_limit, max_file_size=max_file_size)
|
||||
tags_string=u"")
|
||||
print(_(u"""Successfully submitted {filename}!
|
||||
Be sure to look at the Media Processing Panel on your website to be sure it
|
||||
uploaded successfully.""".format(filename=filename)))
|
||||
|
@ -52,8 +52,6 @@ def post_entry(request):
|
||||
_log.debug('File field not found')
|
||||
raise BadRequest()
|
||||
|
||||
upload_limit, max_file_size = get_upload_file_limits(request.user)
|
||||
|
||||
callback_url = request.form.get('callback_url')
|
||||
if callback_url:
|
||||
callback_url = six.text_type(callback_url)
|
||||
@ -66,7 +64,6 @@ def post_entry(request):
|
||||
description=six.text_type(request.form.get('description')),
|
||||
license=six.text_type(request.form.get('license', '')),
|
||||
tags_string=six.text_type(request.form.get('tags', '')),
|
||||
upload_limit=upload_limit, max_file_size=max_file_size,
|
||||
callback_url=callback_url)
|
||||
|
||||
return json_response(get_entry_serializable(entry, request.urlgen))
|
||||
|
@ -128,16 +128,13 @@ def pwg_images_addSimple(request):
|
||||
if not check_file_field(request, 'image'):
|
||||
raise BadRequest()
|
||||
|
||||
upload_limit, max_file_size = get_upload_file_limits(request.user)
|
||||
|
||||
try:
|
||||
entry = submit_media(
|
||||
mg_app=request.app, user=request.user,
|
||||
submitted_file=request.files['image'],
|
||||
filename=request.files['image'].filename,
|
||||
title=six.text_type(form.name.data),
|
||||
description=six.text_type(form.comment.data),
|
||||
upload_limit=upload_limit, max_file_size=max_file_size)
|
||||
description=six.text_type(form.comment.data))
|
||||
|
||||
collection_id = form.category.data
|
||||
if collection_id > 0:
|
||||
|
@ -103,7 +103,6 @@ class UserPastUploadLimit(UploadLimitError):
|
||||
def submit_media(mg_app, user, submitted_file, filename,
|
||||
title=None, description=None,
|
||||
license=None, metadata=None, tags_string=u"",
|
||||
upload_limit=None, max_file_size=None,
|
||||
callback_url=None, urlgen=None,):
|
||||
"""
|
||||
Args:
|
||||
@ -119,12 +118,11 @@ def submit_media(mg_app, user, submitted_file, filename,
|
||||
- license: license for this media entry
|
||||
- tags_string: comma separated string of tags to be associated
|
||||
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 and assign a public
|
||||
ID used in the API (very important).
|
||||
"""
|
||||
upload_limit, max_file_size = get_upload_file_limits(user)
|
||||
if upload_limit and user.uploaded >= upload_limit:
|
||||
raise UserPastUploadLimit()
|
||||
|
||||
|
@ -76,7 +76,6 @@ def submit_start(request):
|
||||
description=six.text_type(submit_form.description.data),
|
||||
license=six.text_type(submit_form.license.data) or None,
|
||||
tags_string=submit_form.tags.data,
|
||||
upload_limit=upload_limit, max_file_size=max_file_size,
|
||||
urlgen=request.urlgen)
|
||||
|
||||
if submit_form.collection and submit_form.collection.data:
|
||||
|
Loading…
x
Reference in New Issue
Block a user