def save(self, addon, commit=True): if self.cleaned_data["icon_upload_hash"]: upload_hash = self.cleaned_data["icon_upload_hash"] upload_path = os.path.join(settings.TMP_PATH, "icon", upload_hash) dirname = addon.get_icon_dir() destination = os.path.join(dirname, "%s" % addon.id) remove_icons(destination) tasks.resize_icon.delay(upload_path, destination, amo.ADDON_ICON_SIZES, set_modified_on=[addon]) return super(AppFormMedia, self).save(commit)
def save_icon(webapp, content): tmp_dst = os.path.join(settings.TMP_PATH, 'icon', uuid.uuid4().hex) with storage.open(tmp_dst, 'wb') as fd: fd.write(content) dirname = webapp.get_icon_dir() destination = os.path.join(dirname, '%s' % webapp.id) remove_icons(destination) resize_icon.delay(tmp_dst, destination, amo.ADDON_ICON_SIZES, set_modified_on=[webapp]) webapp.icon_type = 'image/png' webapp.save()
def save(self, addon, commit=True): if self.cleaned_data['icon_upload_hash']: upload_hash = self.cleaned_data['icon_upload_hash'] upload_path = path.path(settings.TMP_PATH) / 'icon' / upload_hash dirname = addon.get_icon_dir() destination = os.path.join(dirname, '%s' % addon.id) remove_icons(destination) tasks.resize_icon.delay(upload_path, destination, amo.ADDON_ICON_SIZES) return super(AddonFormMedia, self).save(commit)
def save(self, addon, commit=True): if self.cleaned_data['icon_upload_hash']: upload_hash = self.cleaned_data['icon_upload_hash'] upload_path = os.path.join(settings.TMP_PATH, 'icon', upload_hash) dirname = addon.get_icon_dir() destination = os.path.join(dirname, '%s' % addon.id) remove_icons(destination) tasks.resize_icon.delay(upload_path, destination, amo.APP_ICON_SIZES, set_modified_on=[addon]) return super(AppFormMedia, self).save(commit)
def save_icon(webapp, content): tmp_dst = os.path.join(settings.TMP_PATH, 'icon', uuid.uuid4().hex) with storage.open(tmp_dst, 'wb') as fd: fd.write(content) dirname = webapp.get_icon_dir() destination = os.path.join(dirname, '%s' % webapp.id) remove_icons(destination) resize_icon.delay(tmp_dst, destination, amo.ADDON_ICON_SIZES, set_modified_on=[webapp]) # Need to set the icon type so .get_icon_url() works # normally submit step 4 does it through AddonFormMedia, # but we want to beat them to the punch. # resize_icon outputs pngs, so we know it's 'image/png' webapp.icon_type = 'image/png' webapp.save()
def save_icon(webapp, content): tmp_path = path.path(settings.TMP_PATH) / "icon" if not os.path.exists(tmp_path): os.makedirs(tmp_path) tmp_dst = tmp_path / uuid.uuid4().hex with open(tmp_dst, "wb") as fd: fd.write(content) dirname = webapp.get_icon_dir() destination = os.path.join(dirname, "%s" % webapp.id) remove_icons(destination) resize_icon.delay(tmp_dst, destination, amo.ADDON_ICON_SIZES, set_modified_on=[webapp]) # Need to set the icon type so .get_icon_url() works # normally submit step 4 does it through AddonFormMedia, # but we want to beat them to the punch. # resize_icon outputs pngs, so we know it's 'image/png' webapp.icon_type = "image/png" webapp.save()