From 6c0678576aa64251b5a34e04541d4cfd36811f2e Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Thu, 28 Jan 2016 15:10:03 +0700 Subject: [PATCH] Fix #928 - cleanup to avoid duplicated get_upload_file_limits Signed-off-by: Loic Dachary --- mediagoblin/gmg_commands/addmedia.py | 5 +---- mediagoblin/gmg_commands/batchaddmedia.py | 5 +---- mediagoblin/plugins/api/views.py | 3 --- mediagoblin/plugins/piwigo/views.py | 5 +---- mediagoblin/submit/lib.py | 4 +--- mediagoblin/submit/views.py | 1 - 6 files changed, 4 insertions(+), 19 deletions(-) diff --git a/mediagoblin/gmg_commands/addmedia.py b/mediagoblin/gmg_commands/addmedia.py index 8cbfc806..9685d5a5 100644 --- a/mediagoblin/gmg_commands/addmedia.py +++ b/mediagoblin/gmg_commands/addmedia.py @@ -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: diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py index 2ad7e39e..274d72bc 100644 --- a/mediagoblin/gmg_commands/batchaddmedia.py +++ b/mediagoblin/gmg_commands/batchaddmedia.py @@ -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))) diff --git a/mediagoblin/plugins/api/views.py b/mediagoblin/plugins/api/views.py index 23341065..fdd22ace 100644 --- a/mediagoblin/plugins/api/views.py +++ b/mediagoblin/plugins/api/views.py @@ -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)) diff --git a/mediagoblin/plugins/piwigo/views.py b/mediagoblin/plugins/piwigo/views.py index ab741a72..30c7ffa2 100644 --- a/mediagoblin/plugins/piwigo/views.py +++ b/mediagoblin/plugins/piwigo/views.py @@ -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: diff --git a/mediagoblin/submit/lib.py b/mediagoblin/submit/lib.py index 2edea70f..4979def8 100644 --- a/mediagoblin/submit/lib.py +++ b/mediagoblin/submit/lib.py @@ -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() diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py index be473615..7bbfb645 100644 --- a/mediagoblin/submit/views.py +++ b/mediagoblin/submit/views.py @@ -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: -- 2.25.1