Ticket #928: 0001-Fix-928-cleanup-to-avoid-duplicated-get_upload_file_.patch

File 0001-Fix-928-cleanup-to-avoid-duplicated-get_upload_file_.patch, 6.6 KB (added by Loic Dachary, 9 years ago)
  • mediagoblin/gmg_commands/addmedia.py

    From 7a68a3051808a68165b6bb341e8647912b88f2ac Mon Sep 17 00:00:00 2001
    From: Loic Dachary <loic@dachary.org>
    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 <loic@dachary.org>
    ---
     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 8cbfc80..9685d5a 100644
    a b def addmedia(args):  
    8585        print("Can't find a file with filename '%s'" % args.filename)
    8686        return
    8787
    88     upload_limit, max_file_size = get_upload_file_limits(user)
    89 
    9088    def maybe_unicodeify(some_string):
    9189        # this is kinda terrible
    9290        if some_string is None:
    def addmedia(args):  
    103101            title=maybe_unicodeify(args.title),
    104102            description=maybe_unicodeify(args.description),
    105103            license=maybe_unicodeify(args.license),
    106             tags_string=maybe_unicodeify(args.tags) or u"",
    107             upload_limit=upload_limit, max_file_size=max_file_size)
     104            tags_string=maybe_unicodeify(args.tags) or u"")
    108105    except FileUploadLimit:
    109106        print("This file is larger than the upload limits for this site.")
    110107    except UserUploadLimit:
  • mediagoblin/gmg_commands/batchaddmedia.py

    diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py
    index 2ad7e39..274d72b 100644
    a b def batchaddmedia(args):  
    7373                    username=args.username)))
    7474        return
    7575
    76     upload_limit, max_file_size = get_upload_file_limits(user)
    7776    temp_files = []
    7877
    7978    if os.path.isfile(args.metadata_path):
    def batchaddmedia(args):  
    8786
    8887    abs_metadata_filename = os.path.abspath(metadata_path)
    8988    abs_metadata_dir = os.path.dirname(abs_metadata_filename)
    90     upload_limit, max_file_size = get_upload_file_limits(user)
    9189
    9290    def maybe_unicodeify(some_string):
    9391        # this is kinda terrible
    FAIL: Local file {filename} could not be accessed.  
    159157                description=maybe_unicodeify(description),
    160158                license=maybe_unicodeify(license),
    161159                metadata=json_ld_metadata,
    162                 tags_string=u"",
    163                 upload_limit=upload_limit, max_file_size=max_file_size)
     160                tags_string=u"")
    164161            print(_(u"""Successfully submitted {filename}!
    165162Be sure to look at the Media Processing Panel on your website to be sure it
    166163uploaded successfully.""".format(filename=filename)))
  • mediagoblin/plugins/api/views.py

    diff --git a/mediagoblin/plugins/api/views.py b/mediagoblin/plugins/api/views.py
    index 2334106..fdd22ac 100644
    a b def post_entry(request):  
    5252        _log.debug('File field not found')
    5353        raise BadRequest()
    5454
    55     upload_limit, max_file_size = get_upload_file_limits(request.user)
    56 
    5755    callback_url = request.form.get('callback_url')
    5856    if callback_url:
    5957        callback_url = six.text_type(callback_url)
    def post_entry(request):  
    6664            description=six.text_type(request.form.get('description')),
    6765            license=six.text_type(request.form.get('license', '')),
    6866            tags_string=six.text_type(request.form.get('tags', '')),
    69             upload_limit=upload_limit, max_file_size=max_file_size,
    7067            callback_url=callback_url)
    7168
    7269        return json_response(get_entry_serializable(entry, request.urlgen))
  • mediagoblin/plugins/piwigo/views.py

    diff --git a/mediagoblin/plugins/piwigo/views.py b/mediagoblin/plugins/piwigo/views.py
    index ab741a7..30c7ffa 100644
    a b def pwg_images_addSimple(request):  
    128128    if not check_file_field(request, 'image'):
    129129        raise BadRequest()
    130130
    131     upload_limit, max_file_size = get_upload_file_limits(request.user)
    132 
    133131    try:
    134132        entry = submit_media(
    135133            mg_app=request.app, user=request.user,
    136134            submitted_file=request.files['image'],
    137135            filename=request.files['image'].filename,
    138136            title=six.text_type(form.name.data),
    139             description=six.text_type(form.comment.data),
    140             upload_limit=upload_limit, max_file_size=max_file_size)
     137            description=six.text_type(form.comment.data))
    141138
    142139        collection_id = form.category.data
    143140        if collection_id > 0:
  • mediagoblin/submit/lib.py

    diff --git a/mediagoblin/submit/lib.py b/mediagoblin/submit/lib.py
    index 2edea70..4979def 100644
    a b class UserPastUploadLimit(UploadLimitError):  
    103103def submit_media(mg_app, user, submitted_file, filename,
    104104                 title=None, description=None,
    105105                 license=None, metadata=None, tags_string=u"",
    106                  upload_limit=None, max_file_size=None,
    107106                 callback_url=None, urlgen=None,):
    108107    """
    109108    Args:
    def submit_media(mg_app, user, submitted_file, filename,  
    119118     - license: license for this media entry
    120119     - tags_string: comma separated string of tags to be associated
    121120       with this entry
    122      - upload_limit: size in megabytes that's the per-user upload limit
    123      - max_file_size: maximum size each file can be that's uploaded
    124121     - callback_url: possible post-hook to call after submission
    125122     - urlgen: if provided, used to do the feed_url update and assign a public
    126123               ID used in the API (very important).
    127124    """
     125    upload_limit, max_file_size = get_upload_file_limits(user)
    128126    if upload_limit and user.uploaded >= upload_limit:
    129127        raise UserPastUploadLimit()
    130128
  • mediagoblin/submit/views.py

    diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
    index eb11dfe..6bbe61d 100644
    a b def submit_start(request):  
    7777                    description=six.text_type(submit_form.description.data),
    7878                    license=six.text_type(submit_form.license.data) or None,
    7979                    tags_string=submit_form.tags.data,
    80                     upload_limit=upload_limit, max_file_size=max_file_size,
    8180                    urlgen=request.urlgen)
    8281
    8382                if submit_form.collection and submit_form.collection.data: