Fix #928 - cleanup to avoid duplicated get_upload_file_limits
authorLoic Dachary <loic@dachary.org>
Thu, 28 Jan 2016 08:10:03 +0000 (15:10 +0700)
committerBoris Bobrov <breton@cynicmansion.ru>
Mon, 25 Jul 2016 00:48:33 +0000 (03:48 +0300)
Signed-off-by: Loic Dachary <loic@dachary.org>
mediagoblin/gmg_commands/addmedia.py
mediagoblin/gmg_commands/batchaddmedia.py
mediagoblin/plugins/api/views.py
mediagoblin/plugins/piwigo/views.py
mediagoblin/submit/lib.py
mediagoblin/submit/views.py

index 8cbfc806ba3f4932c6111da2165b068b948e01cd..9685d5a5c80fce47c3e2f13ae08f169effb6dea7 100644 (file)
@@ -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:
index 2ad7e39e418b4493c96f37cd178ab43268aa79d6..274d72bcc3f1ad1dd0d35407095959ee0717504e 100644 (file)
@@ -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)))
index 233410654711bfbf67a2d14df36d09f8e5760ac2..fdd22acebc2f0890071b8c1ed902e065abc1c15d 100644 (file)
@@ -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))
index ab741a7243cca6caff177760d0252ee306c9c5a6..30c7ffa287a66b09fc7154dd3a58197796198d6b 100644 (file)
@@ -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:
index 2edea70f193242a2d36f86cd56a02e6984355bcf..4979def85c5956619556e9b366d1d4bea0520b4d 100644 (file)
@@ -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()
 
index be47361534ca123ada3777f519cf03afaee716a6..7bbfb64502a252c3d71b59e33ab1fadb4e99e302 100644 (file)
@@ -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: