def kanisa_branding(branding_component): try: brand = BrandingInformation(branding_component) except ValueError: return None return brand
def image(self): branding_information = BrandingInformation('podcast') if not branding_information.url: branding_information = BrandingInformation('apple') if not branding_information.url: return None media_url = settings.MEDIA_URL if media_url.startswith('/'): # We've got a relative MEDIA_URL, let's prepend the site # URL. media_url = 'http://%s%s' % (Site.objects.get_current().domain, media_url) return media_url + branding_information.url
def form_valid(self, form): ensure_branding_directory_exists() brand = BrandingInformation(self.kwargs['resource']) brand.clear_cached_hash() dest_name = get_branding_disk_file(self.get_destination_filename()) if os.path.exists(dest_name): delete( os.path.join('kanisa', 'branding', self.get_destination_filename())) with open(dest_name, 'wb') as destination: for chunk in form.files['image'].chunks(): destination.write(chunk) messages.success(self.request, ('Image updated - changes may take ' 'a few minutes to take effect.')) return super(BrandingManagementUpdateView, self).form_valid(form)
def form_valid(self, form): ensure_branding_directory_exists() brand = BrandingInformation(self.kwargs['resource']) brand.clear_cached_hash() dest_name = get_branding_disk_file(self.get_destination_filename()) if os.path.exists(dest_name): delete(os.path.join('kanisa', 'branding', self.get_destination_filename())) with open(dest_name, 'wb') as destination: for chunk in form.files['image'].chunks(): destination.write(chunk) messages.success(self.request, ('Image updated - changes may take ' 'a few minutes to take effect.')) return super(BrandingManagementUpdateView, self).form_valid(form)
def image_or_default(self): if self.image: return self.image branding = BrandingInformation('apple') return branding.url
def image(self): branding_information = BrandingInformation('apple') if not branding_information.url: return None return settings.MEDIA_URL + branding_information.url