Exemplo n.º 1
0
def kanisa_branding(branding_component):
    try:
        brand = BrandingInformation(branding_component)
    except ValueError:
        return None

    return brand
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    def image_or_default(self):
        if self.image:
            return self.image

        branding = BrandingInformation('apple')
        return branding.url
Exemplo n.º 6
0
    def image(self):
        branding_information = BrandingInformation('apple')
        if not branding_information.url:
            return None

        return settings.MEDIA_URL + branding_information.url