Ejemplo n.º 1
0
def upload_ad_creative(image, max_size=MAX_AD_SIZE):
    resolution = ''
    errors = set()
    image = coerce_image(image)
    if image is None or isinstance(image, basestring):
        errors.add('image')

    f = image.file
    if get_filesize(f) > max_size:
        errors.add('image_size')

    image_upload = get_upload(image, max_size=max_size)
    if image_upload:
        resolution, swf_url = image_upload
    else:
        errors.add('image')

    if errors:
        return errors, None

    if resolution:
        rmatch = VALID_RESOLUTION.match(resolution)
        width, height = rmatch.groups()

    return errors, (swf_url, width, height)
Ejemplo n.º 2
0
def upload_teaser(teaser, max_resolution=MAX_TEASER_RES):
    errors = set()
    teaser_url = None
    teaser = coerce_image(teaser)
    teaser_upload = get_upload(teaser, add_actions=False)
    if teaser_upload:
        teaser_res, teaser_url = teaser_upload

        rmatch = VALID_RESOLUTION.match(teaser_res)
        width, height = rmatch.groups()
        if (width, height) != max_resolution:
            errors.add('teaser_size')
    else:
        errors.add('teaser')

    return errors, teaser_url