コード例 #1
0
    def test_icon_too_small(self):
        with local_storage.open(get_image_path('mkt_icon_72.png')) as f:
            errors, upload_hash = check_upload(f, 'icon', 'image/png')
            ok_(errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'icon', upload_hash)
            ok_(private_storage.exists(tmp_img_path))
コード例 #2
0
ファイル: test_utils_.py プロジェクト: jamesthechamp/zamboni
    def test_promo_img_too_small(self):
        with local_storage.open(get_image_path('preview.jpg')) as f:
            errors, upload_hash = check_upload(f, 'promo_img', 'image/png')
            ok_(errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'promo_img',
                                        upload_hash)
            ok_(os.path.isfile(tmp_img_path))
コード例 #3
0
ファイル: test_utils_.py プロジェクト: Fjoerfoks/zamboni
    def test_preview_too_small(self):
        with local_storage.open(get_image_path('mkt_icon_72.png')) as f:
            errors, upload_hash = check_upload(f, 'preview', 'image/png')
            ok_(errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'preview',
                                        upload_hash)
            ok_(private_storage.exists(tmp_img_path))
コード例 #4
0
ファイル: forms.py プロジェクト: gurumukhi/zamboni
    def clean_file(self):
        file_ = self.cleaned_data.get("file", {})
        file_obj = parse(file_)
        errors, hash_ = check_upload(file_obj, self.upload_type, file_["type"])
        if errors:
            raise forms.ValidationError(errors)

        self.hash_ = hash_
        return file_
コード例 #5
0
ファイル: test_utils_.py プロジェクト: Fjoerfoks/zamboni
    def test_promo_img_ok(self):
        with local_storage.open(get_image_path('game_1050.jpg')) as f:
            errors, upload_hash = check_upload(f, 'promo_img', 'image/png')
            ok_(not errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'promo_img',
                                        upload_hash)
            ok_(private_storage.exists(tmp_img_path))
コード例 #6
0
ファイル: forms.py プロジェクト: vinu76jsr/zamboni
    def clean_file(self):
        file_ = self.cleaned_data.get('file', {})
        file_obj = parse(file_)
        errors, hash_ = check_upload(file_obj, 'preview', file_['type'])
        if errors:
            raise forms.ValidationError(errors)

        self.hash_ = hash_
        return file_
コード例 #7
0
ファイル: test_utils_.py プロジェクト: jamesthechamp/zamboni
    def test_icon_ok(self):
        with local_storage.open(get_image_path('mozilla-sq.png')) as f:
            errors, upload_hash = check_upload(f, 'icon', 'image/png')
            ok_(not errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'icon',
                                        upload_hash)
            ok_(os.path.isfile(tmp_img_path))
コード例 #8
0
    def test_promo_img_ok(self):
        with local_storage.open(get_image_path('game_1050.jpg')) as f:
            errors, upload_hash = check_upload(f, 'promo_img', 'image/png')
            ok_(not errors)
            ok_(upload_hash)

            tmp_img_path = os.path.join(settings.TMP_PATH, 'promo_img',
                                        upload_hash)
            ok_(private_storage.exists(tmp_img_path))
コード例 #9
0
ファイル: forms.py プロジェクト: flyun/zamboni
    def clean_file(self):
        file_ = self.cleaned_data.get('file', {})
        file_obj = parse(file_)
        errors, hash_ = check_upload(file_obj, 'preview', file_['type'])
        if errors:
            raise forms.ValidationError(errors)

        self.hash_ = hash_
        return file_
コード例 #10
0
ファイル: forms.py プロジェクト: shahbaz17/zamboni
    def clean_promo_img(self):
        image = self.cleaned_data[self.upload_type]
        errors, upload_hash = check_upload(image, self.upload_type,
                                           image.content_type)
        if errors:
            log.info('Promo img errors: %s' % errors)
            raise forms.ValidationError(errors)

        self.upload_hash = upload_hash
        return image
コード例 #11
0
ファイル: forms.py プロジェクト: ayushagrawal288/zamboni
    def clean_promo_img(self):
        image = self.cleaned_data[self.upload_type]
        errors, upload_hash = check_upload(image, self.upload_type,
                                           image.content_type)
        if errors:
            log.info('Promo img errors: %s' % errors)
            raise forms.ValidationError(errors)

        self.upload_hash = upload_hash
        return image
コード例 #12
0
ファイル: forms.py プロジェクト: Sancus/zamboni
    def clean_file(self):
        file_ = self.cleaned_data.get('file', {})
        try:
            if not set(['data', 'type']).issubset(set(file_.keys())):
                raise forms.ValidationError('Type and data are required.')
        except AttributeError:
            raise forms.ValidationError('File must be a dictionary.')

        file_obj = StringIO.StringIO(base64.b64decode(file_['data']))
        errors, hash_ = check_upload(file_obj, 'graphic', file_['type'])
        if errors:
            raise forms.ValidationError(errors)

        self.hash_ = hash_
        return file_
コード例 #13
0
    def clean_file(self):
        file_ = self.cleaned_data.get('file', {})
        try:
            if not set(['data', 'type']).issubset(set(file_.keys())):
                raise forms.ValidationError('Type and data are required.')
        except AttributeError:
            raise forms.ValidationError('File must be a dictionary.')

        file_obj = StringIO.StringIO(base64.b64decode(file_['data']))
        errors, hash_ = check_upload(file_obj, 'image', file_['type'])
        if errors:
            raise forms.ValidationError(errors)

        self.hash_ = hash_
        return file_
コード例 #14
0
ファイル: views.py プロジェクト: ngokevin/zamboni
def ajax_upload_media(request, upload_type):
    errors = []
    upload_hash = ""

    if "upload_image" in request.FILES:
        upload_preview = request.FILES["upload_image"]
        upload_preview.seek(0)
        content_type = upload_preview.content_type
        errors, upload_hash = check_upload(upload_preview, upload_type, content_type)

    else:
        errors.append(_("There was an error uploading your preview."))

    if errors:
        upload_hash = ""

    return {"upload_hash": upload_hash, "errors": errors}
コード例 #15
0
ファイル: views.py プロジェクト: j-barron/zamboni
def ajax_upload_media(request, upload_type):
    errors = []
    upload_hash = ''

    if 'upload_image' in request.FILES:
        upload_preview = request.FILES['upload_image']
        upload_preview.seek(0)
        content_type = upload_preview.content_type
        errors, upload_hash = check_upload(upload_preview, upload_type,
                                           content_type)

    else:
        errors.append(_('There was an error uploading your preview.'))

    if errors:
        upload_hash = ''

    return {'upload_hash': upload_hash, 'errors': errors}
コード例 #16
0
ファイル: views.py プロジェクト: bearstech/zamboni
def ajax_upload_media(request, upload_type):
    errors = []
    upload_hash = ''

    if 'upload_image' in request.FILES:
        upload_preview = request.FILES['upload_image']
        upload_preview.seek(0)
        content_type = upload_preview.content_type
        errors, upload_hash = check_upload(upload_preview, upload_type,
                                           content_type)

    else:
        errors.append(_('There was an error uploading your preview.'))

    if errors:
        upload_hash = ''

    return {'upload_hash': upload_hash, 'errors': errors}
コード例 #17
0
ファイル: test_utils_.py プロジェクト: zzdjk6/zamboni
 def test_valid(self):
     with storage.open(self.preview_image()) as f:
         errors, hash = check_upload(f, 'preview', 'image/png')
         assert not errors
コード例 #18
0
 def test_upload_type_not_recognized(self):
     with self.assertRaises(ValueError):
         check_upload([], 'graphic', 'image/jpg')
コード例 #19
0
ファイル: test_utils_.py プロジェクト: jamesthechamp/zamboni
 def test_upload_type_not_recognized(self):
     with self.assertRaises(ValueError):
         check_upload([], 'graphic', 'image/jpg')
コード例 #20
0
 def test_valid(self):
     with storage.open(get_image_path('preview.jpg')) as f:
         errors, hash = check_upload(f, 'preview', 'image/png')
         assert not errors
コード例 #21
0
ファイル: test_utils_.py プロジェクト: zzdjk6/zamboni
 def test_not_valid(self):
     with self.assertRaises(ValueError):
         check_upload([], 'graphic', 'image/jpg')