def render(self):
        from render import render_asset
        if self.is_editable(): 
    
            text = self.file.read()
            
            render = render_asset(text, self.theme.shop)
            try:
                file = self.assetrendering.file
                if file.storage.exists(file.name):
                    file.storage.delete(file.name)
                file.save(file.name, ContentFile(str(render)))
            except AssetRendering.DoesNotExist:
                asset_rendering = AssetRendering(asset=self)
                asset_rendering.file.save("%s_render_%s" % (self.theme.shop.name, self.name),ContentFile(str(render)))
                asset_rendering.save()


            render_secure = render_asset(text, self.theme.shop, is_secure=True)
            try:
                file = self.assetrenderingsecure.file
                if file.storage.exists(file.name):
                    file.storage.delete(file.name)
                file.save(file.name, ContentFile(str(render_secure)))
            except AssetRenderingSecure.DoesNotExist:
                asset_rendering_secure = AssetRenderingSecure(asset=self)
                asset_rendering_secure.file.save("%s_render_secure_%s" % (self.theme.shop.name, self.name),ContentFile(str(render_secure)))
                asset_rendering_secure.save()
Exemplo n.º 2
0
    def render(self):
        from render import render_asset
        if self.is_editable():

            text = self.file.read()

            render = render_asset(text, self.theme.shop)
            try:
                file = self.assetrendering.file
                if file.storage.exists(file.name):
                    file.storage.delete(file.name)
                file.save(file.name, ContentFile(str(render)))
            except AssetRendering.DoesNotExist:
                asset_rendering = AssetRendering(asset=self)
                asset_rendering.file.save(
                    "%s_render_%s" % (self.theme.shop.name, self.name),
                    ContentFile(str(render)))
                asset_rendering.save()

            render_secure = render_asset(text, self.theme.shop, is_secure=True)
            try:
                file = self.assetrenderingsecure.file
                if file.storage.exists(file.name):
                    file.storage.delete(file.name)
                file.save(file.name, ContentFile(str(render_secure)))
            except AssetRenderingSecure.DoesNotExist:
                asset_rendering_secure = AssetRenderingSecure(asset=self)
                asset_rendering_secure.file.save(
                    "%s_render_secure_%s" % (self.theme.shop.name, self.name),
                    ContentFile(str(render_secure)))
                asset_rendering_secure.save()
Exemplo n.º 3
0
 def clean_text(self):
     text = self.cleaned_data['text']
     try:
         render_asset(text, self.shop)
     except (Exception), e:
         raise forms.ValidationError(e)
Exemplo n.º 4
0
 def clean_text(self):
     text = self.cleaned_data['text']
     try:
         render_asset(text, self.shop)
     except (Exception), e:
         raise forms.ValidationError(e)