Example #1
0
    def save(self, obj, commit=True):
        if self.upload_type in self.cleaned_data:
            upload_path = os.path.join(settings.TMP_PATH, self.upload_type,
                                       self.upload_hash)

            dirname = obj.get_promo_img_dir()
            destination = os.path.join(dirname, '%s' % obj.id)

            remove_promo_imgs(destination)
            resize_promo_imgs(upload_path, destination,
                              mkt.PROMO_IMG_SIZES, set_modified_on=[obj])

            log.info('Finished processing promo img for %s' % obj.id)
Example #2
0
def save_promo_imgs(obj, img_content):
    """
    Saves the promo image for `obj` to its final destination.
    `obj` can be an app or a website.
    """
    tmp_dst = os.path.join(settings.TMP_PATH, "promo_imgs", uuid.uuid4().hex)
    with storage.open(tmp_dst, "wb") as fd:
        fd.write(img_content)

    dirname = obj.get_promo_img_dir()
    destination = os.path.join(dirname, "%s" % obj.pk)
    remove_promo_imgs(destination)
    resize_promo_imgs(tmp_dst, destination, mkt.PROMO_IMG_SIZES, set_modified_on=[obj])
Example #3
0
def save_promo_imgs(obj, img_content):
    """
    Saves the promo image for `obj` to its final destination.
    `obj` can be an app or a website.
    """
    tmp_dst = os.path.join(settings.TMP_PATH, 'promo_imgs', uuid.uuid4().hex)
    with private_storage.open(tmp_dst, 'wb') as fd:
        fd.write(img_content)

    dirname = obj.get_promo_img_dir()
    destination = os.path.join(dirname, '%s' % obj.pk)
    remove_promo_imgs(destination)
    resize_promo_imgs(
        tmp_dst, destination, mkt.PROMO_IMG_SIZES,
        set_modified_on=[obj])
Example #4
0
    def save(self, obj, commit=True):
        if self.upload_type in self.cleaned_data:
            upload_path = os.path.join(settings.TMP_PATH, self.upload_type,
                                       self.upload_hash)

            dirname = obj.get_promo_img_dir()
            destination = os.path.join(dirname, '%s' % obj.id)

            remove_promo_imgs(destination)
            resize_promo_imgs(upload_path,
                              destination,
                              mkt.PROMO_IMG_SIZES,
                              set_modified_on=[obj])

            log.info('Finished processing promo img for %s' % obj.id)