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