Beispiel #1
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't set thumbnail on a non-folderish object !")

        form = getattr(self.request, 'form', {})
        kwargs.update(form)

        filename = kwargs.get('filename', 'cover.png')

        convert = getUtility(IConvert)
        img = convert(data=kwargs.get('svg', ''),
                      data_from='svg',
                      data_to='png')

        if not img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory('Image', id=filename)
        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField('image').getMutator(obj)(img)
        self.context.getOrdering().moveObjectsToTop(ids=[obj.getId()])
        return _("Success")
Beispiel #2
0
    def submit_charts(self):
        """ Submit
        """
        mutator = queryAdapter(self.context, IVisualizationConfig)
        data = {}
        data['chartsconfig'] = json.loads(self.request['charts'])
        mutator.edit_view('googlechart.googlecharts', **data)

        if not IFolderish.providedBy(self.context):
            return "Changes saved, but can't save png" + \
                    "chart on a non-folderish object!"

        previews = [
            "googlechart.googledashboard.preview.png",
            "googlechart.motionchart.preview.png",
            "googlechart.organizational.preview.png",
            "googlechart.imagechart.preview.png",
            "googlechart.sparkline.preview.png",
            "googlechart.table.preview.png",
            "googlechart.annotatedtimeline.preview.png",
            "googlechart.treemap.preview.png"
        ]
        for previewname in previews:
            if not self.context.get(previewname, None):
                img = self.context.restrictedTraverse("++resource++" +
                                                      previewname)
                self.context.invokeFactory('Image',
                                           id=previewname,
                                           title=previewname,
                                           image=img.GET())

        notify(ChartsChanged(self.context, config=data))

        return _('Changes saved')
Beispiel #3
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't save png chart on a non-folderish object !")
        form = getattr(self.request, 'form', {})
        kwargs.update(form)
        filename = kwargs.get('filename', 'img')
        chart_url = self.context.absolute_url() + "#" + "tab-" + filename
        filename = filename + ".png"
        sp = self.siteProperties
        qr_size = sp.get('googlechart.qrcode_size', '70')
        if qr_size == '0':
            qr_size = '70'
        qr_url = (u"http://chart.apis.google.com"
                  "/chart?cht=qr&chld=H|0&chs=%sx%s&chl=%s" %
                  (qr_size, qr_size, urllib2.quote(chart_url)))
        self.request.form['qr_url'] = qr_url
        img = super(SavePNGChart, self).__call__()

        if not img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory('Image', id=filename)
        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField('image').getMutator(obj)(img)
        return _("Success")
def migrate_imagecharts(context):
    """ Migrate dashboard image charts"""
    ctool = getToolByName(context, 'portal_catalog')
    brains = ctool.unrestrictedSearchResults(portal_type='DavizVisualization')
    previews = [
        "googlechart.motionchart.preview.png",
        "googlechart.organizational.preview.png",
        "googlechart.imagechart.preview.png",
        "googlechart.sparkline.preview.png",
        "googlechart.table.preview.png",
        "googlechart.annotatedtimeline.preview.png",
        "googlechart.treemap.preview.png"
    ]

    logger.info('Migrating %s Visualizations ...', len(brains))

    for brain in brains:
        logger.info('Migrating %s', brain.getURL())

        visualization = brain.getObject()
        if IFolderish.providedBy(visualization):
            for previewname in previews:
                if not visualization.get(previewname, None):
                    logger.info('Create img: %s', previewname)

                    img = context.restrictedTraverse(
                        '++resource++' + previewname)
                    visualization.invokeFactory('Image',
                        id=previewname,
                        title=previewname,
                        image=img.GET())
                else:
                    logger.info('Img: %s already exists', previewname)

    logger.info('Migrating Visualizations ... DONE')
Beispiel #5
0
def migrate_imagecharts(context):
    """ Migrate dashboard image charts"""
    ctool = getToolByName(context, 'portal_catalog')
    brains = ctool.unrestrictedSearchResults(portal_type='DavizVisualization')
    previews = [
        "googlechart.motionchart.preview.png",
        "googlechart.organizational.preview.png",
        "googlechart.imagechart.preview.png",
        "googlechart.sparkline.preview.png", "googlechart.table.preview.png",
        "googlechart.annotatedtimeline.preview.png",
        "googlechart.treemap.preview.png"
    ]

    logger.info('Migrating %s Visualizations ...', len(brains))

    for brain in brains:
        logger.info('Migrating %s', brain.getURL())

        visualization = brain.getObject()
        if IFolderish.providedBy(visualization):
            for previewname in previews:
                if not visualization.get(previewname, None):
                    logger.info('Create img: %s', previewname)

                    img = context.restrictedTraverse('++resource++' +
                                                     previewname)
                    visualization.invokeFactory('Image',
                                                id=previewname,
                                                title=previewname,
                                                image=img.GET())
                else:
                    logger.info('Img: %s already exists', previewname)

    logger.info('Migrating Visualizations ... DONE')
Beispiel #6
0
    def submit_charts(self):
        """ Submit
        """
        mutator = queryAdapter(self.context, IVisualizationConfig)
        data = {}
        data['chartsconfig'] = json.loads(self.request['charts'])
        mutator.edit_view('googlechart.googlecharts', **data)

        if not IFolderish.providedBy(self.context):
            return "Changes saved, but can't save png" + \
                    "chart on a non-folderish object!"

        previews = ["googlechart.googledashboard.preview.png",
                    "googlechart.motionchart.preview.png",
                    "googlechart.organizational.preview.png",
                    "googlechart.imagechart.preview.png",
                    "googlechart.sparkline.preview.png",
                    "googlechart.table.preview.png",
                    "googlechart.annotatedtimeline.preview.png",
                    "googlechart.treemap.preview.png"]
        for previewname in previews:
            if not self.context.get(previewname, None):
                img = self.context.restrictedTraverse(
                    "++resource++" + previewname)
                self.context.invokeFactory('Image',
                    id=previewname,
                    title=previewname,
                    image=img.GET())

        notify(ChartsChanged(self.context, config=data))

        return 'Changes saved'
Beispiel #7
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't save png chart on a non-folderish object !")
        form = getattr(self.request, 'form', {})
        kwargs.update(form)
        filename = kwargs.get('filename', 'img')
        chart_url = self.context.absolute_url() + "#" + "tab-" + filename
        filename = filename + ".png"
        sp = self.siteProperties
        qr_size = sp.get('googlechart.qrcode_size', '70')
        if qr_size == '0':
            qr_size = '70'
        qr_url = "http://chart.apis.google.com/chart?cht=qr&chld=H|0&chs=" + \
            qr_size + "x" + qr_size + "&chl=" + urllib2.quote(chart_url)
        self.request.form['qr_url'] = qr_url
        img = super(SavePNGChart, self).__call__()

        if not img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory('Image', id=filename)
        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField('image').getMutator(obj)(img)
        return _("Success")
Beispiel #8
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't set thumbnail on a non-folderish object !")

        form = getattr(self.request, 'form', {})
        kwargs.update(form)

        filename = kwargs.get('filename', 'cover.png')
        img = None
        convert = getUtility(IConvert)
        if kwargs.get('svg', '') != '':
            img = convert(data=kwargs.get('svg', ''),
                          data_from='svg',
                          data_to='png')
        if kwargs.get('imageChart_url', '') != '':
            try:
                img_con = urllib2.urlopen(kwargs.get('imageChart_url'),
                                          timeout=10)
                img = img_con.read()
                img_con.close()
            except Exception:
                img = None

        if not img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory('Image', id=filename)
        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField('image').getMutator(obj)(img)
        self.context.getOrdering().moveObjectsToTop(ids=[obj.getId()])
        notify(InvalidateCacheEvent(obj))
        return _("Success")
Beispiel #9
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't save png chart on a non-folderish object !")
        form = getattr(self.request, "form", {})
        kwargs.update(form)
        filename = kwargs.get("filename", "img")
        chart_url = self.context.absolute_url() + "#" + "tab-" + filename
        filename = filename + ".png"
        sp = self.siteProperties
        qr_size = sp.get("googlechart.qrcode_size", "70")
        if qr_size == "0":
            qr_size = "70"
        qr_url = u"http://chart.apis.google.com" "/chart?cht=qr&chld=H|0&chs=%sx%s&chl=%s" % (
            qr_size,
            qr_size,
            urllib2.quote(chart_url),
        )
        self.request.form["qr_url"] = qr_url
        img = super(SavePNGChart, self).__call__()

        if not img:
            return _("ERROR: An error occured while exporting your image. " "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory("Image", id=filename)
        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField("image").getMutator(obj)(img)
        return _("Success")
Beispiel #10
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't set thumbnail on a non-folderish object !")

        form = getattr(self.request, 'form', {})
        kwargs.update(form)

        filename = kwargs.get('filename', 'cover.png')

        convert = getUtility(IConvert)
        if kwargs.get('svg', '') != '':
            img = convert(
                data=kwargs.get('svg', ''),
                data_from='svg',
                data_to='png'
            )
        if kwargs.get('imageChart_url', '') != '':
            img_con = urllib2.urlopen(kwargs.get('imageChart_url'))
            img = img_con.read()
            img_con.close()

        if not img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")


        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory('Image', id=filename)
        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField('image').getMutator(obj)(img)
        self.context.getOrdering().moveObjectsToTop(ids=[obj.getId()])
        notify(ObjectModifiedEvent(obj))
        return _("Success")
Beispiel #11
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't set thumbnail on a non-folderish object !")

        form = getattr(self.request, "form", {})
        kwargs.update(form)

        filename = kwargs.get("filename", "cover.png")

        convert = getUtility(IConvert)
        if kwargs.get("svg", "") != "":
            img = convert(data=kwargs.get("svg", ""), data_from="svg", data_to="png")
        if kwargs.get("imageChart_url", "") != "":
            try:
                img_con = urllib2.urlopen(kwargs.get("imageChart_url"), timeout=10)
                img = img_con.read()
                img_con.close()
            except Exception:
                img = None

        if not img:
            return _("ERROR: An error occured while exporting your image. " "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory("Image", id=filename)
        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField("image").getMutator(obj)(img)
        self.context.getOrdering().moveObjectsToTop(ids=[obj.getId()])
        notify(InvalidateCacheEvent(obj))
        return _("Success")
Beispiel #12
0
def migrate_imagecharts(context):
    """ Migrate dashboard image charts"""
    ctool = getToolByName(context, 'portal_catalog')
    brains = ctool.unrestrictedSearchResults(portal_type='DavizVisualization')
    for brain in brains:
        visualization = brain.getObject()
        if IFolderish.providedBy(visualization):
            tabs = queryMultiAdapter((visualization, context.REQUEST),
                                     name='daviz-view.html').tabs

            for tab in tabs:
                if tab['name'] == 'googlechart.googledashboard':
                    previewname = tab['name'] + '.preview.png'
                    if not visualization.get(previewname, None):
                        img = context.restrictedTraverse('++resource++' +
                            str(previewname))
                        visualization.invokeFactory('Image',
                            id=previewname,
                            title=previewname,
                            image=img.GET())
Beispiel #13
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't set thumbnail on a non-folderish object !")

        form = getattr(self.request, "form", {})
        kwargs.update(form)

        filename = kwargs.get("filename", "cover.png")

        convert = getUtility(IConvert)
        img = convert(data=kwargs.get("svg", ""), data_from="svg", data_to="png")

        if not img:
            return _("ERROR: An error occured while exporting your image. " "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory("Image", id=filename)
        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField("image").getMutator(obj)(img)
        self.context.getOrdering().moveObjectsToTop(ids=[obj.getId()])
        return _("Success")
Beispiel #14
0
    def save_svg_and_png(self, kwargs):
        """ Save png out of the svg version of the chart
        """
        if not IFolderish.providedBy(self.context):
            return _("Can't save png chart on a non-folderish object !")
        form = getattr(self.request, 'form', {})
        kwargs.update(form)
        filename = kwargs.get('filename', 'img')
        chart_url = self.context.absolute_url() + "#" + "tab-" + filename
        svg_filename = filename + ".svg"
        filename += ".png"
        sp = self.siteProperties
        qr_size = sp.get('googlechart.qrcode_size', '70')
        object_ids = self.context.objectIds()
        if qr_size == '0':
            qr_size = '70'
        qr_url = (
            u"http://chart.apis.google.com"
            "/chart?cht=qr&chld=H|0&chs=%sx%s&chl=%s" % (
                qr_size, qr_size, urllib2.quote(chart_url)))
        self.request.form['qr_url'] = qr_url
        svg_data = kwargs.get('svg', '')
        if not svg_data:
            return _("Success")
        new_svg = False
        if svg_filename not in object_ids:
            new_svg = True
            svg_filename = self.context.invokeFactory('File', id=svg_filename)
        svg_obj = self.context._getOb(svg_filename)
        svg_file_field = svg_obj.getField('file')
        svg_field_data = svg_file_field.getRaw(svg_obj).getIterator().read()
        if svg_field_data and svg_data == svg_field_data:
            return _("Success")
        elif svg_field_data:
            # 21894 svg_data from the form and the data saved within the current
            # svg files sometimes has the clipPath id number changed, otherwise
            # the files are identical in which case we no longer need to perform
            # any svg and image generation
            pattern = re.compile(r'_ABSTRACT_RENDERER_ID_\d+')
            svg_data_match = pattern.search(svg_data).group()
            svg_field_data_matched = pattern.sub(svg_data_match, svg_field_data)
            if svg_data == svg_field_data_matched:
                return _("Success")
        # create image from the current svg
        img = super(SavePNGChart, self).__call__()
        if not img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")
        new_file = False
        if filename not in object_ids:
            new_file = True
            filename = self.context.invokeFactory('Image', id=filename)
        img_obj = self.context._getOb(filename)
        if new_file:
            img_obj.setExcludeFromNav(True)
        image_field = img_obj.getField('image')
        image_field.getMutator(img_obj)(img)
        if new_svg:
            svg_obj.setExcludeFromNav(True)
        svg_file_field.getMutator(svg_obj)(svg_data)

        wftool = getToolByName(svg_obj, "portal_workflow")
        state = wftool.getInfoFor(svg_obj, 'review_state', None)
        if state:
            if state != 'visible':
                workflows = wftool.getWorkflowsFor(svg_obj)
                workflow = workflows[0]
                transitions = workflow.transitions
                available_transitions = [transitions[i['id']] for i in
                                    wftool.getTransitionsFor(svg_obj)]

                to_do = [k for k in available_transitions
                         if k.new_state_id == 'published']

                self.request.form['_no_emails_'] = True
                for item in to_do:
                    workflow.doActionFor(svg_obj, item.id)
                    break
                # then make it public draft
                available_transitions = [transitions[i['id']] for i in
                                        wftool.getTransitionsFor(svg_obj)]

                to_do = [k for k in available_transitions
                         if k.new_state_id == 'visible']

                for item in to_do:
                    workflow.doActionFor(svg_obj, item.id)
                    break
                svg_obj.reindexObject()
        if not new_svg:
            notify(InvalidateCacheEvent(svg_obj))
        return _("Success")
Beispiel #15
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't save png chart on a non-folderish object !")
        form = getattr(self.request, 'form', {})
        kwargs.update(form)
        filename = kwargs.get('filename', 'img')
        chart_url = self.context.absolute_url() + "#" + "tab-" + filename
        svg_filename = filename + ".svg"
        filename = filename + ".png"
        sp = self.siteProperties
        qr_size = sp.get('googlechart.qrcode_size', '70')
        if qr_size == '0':
            qr_size = '70'
        qr_url = (u"http://chart.apis.google.com"
                  "/chart?cht=qr&chld=H|0&chs=%sx%s&chl=%s" %
                  (qr_size, qr_size, urllib2.quote(chart_url)))
        self.request.form['qr_url'] = qr_url
        img = super(SavePNGChart, self).__call__()

        if not img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory('Image', id=filename)

        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField('image').getMutator(obj)(img)

        svg_data = kwargs.get('svg', '')
        if svg_data:
            if svg_filename not in self.context.objectIds():
                svg_filename = self.context.invokeFactory('File',
                                                          id=svg_filename)
            svg_obj = self.context._getOb(svg_filename)
            svg_obj.setExcludeFromNav(True)
            svg_obj.getField('file').getMutator(svg_obj)(kwargs.get('svg', ''))

            wftool = getToolByName(svg_obj, "portal_workflow")
            workflows = wftool.getWorkflowsFor(svg_obj)
            if len(workflows) > 0:
                workflow = workflows[0]
                transitions = workflow.transitions
                state = wftool.getInfoFor(svg_obj, 'review_state')

                if state != 'visible':
                    available_transitions = [
                        transitions[i['id']]
                        for i in wftool.getTransitionsFor(svg_obj)
                    ]

                    to_do = [
                        k for k in available_transitions
                        if k.new_state_id == 'published'
                    ]

                    self.request.form['_no_emails_'] = True
                    for item in to_do:
                        workflow.doActionFor(svg_obj, item.id)
                        break

                    # then make it public draft
                    available_transitions = [
                        transitions[i['id']]
                        for i in wftool.getTransitionsFor(svg_obj)
                    ]

                    to_do = [
                        k for k in available_transitions
                        if k.new_state_id == 'visible'
                    ]

                    for item in to_do:
                        workflow.doActionFor(svg_obj, item.id)
                        break

                svg_obj.reindexObject()
                notify(InvalidateCacheEvent(svg_obj))

        return _("Success")
Beispiel #16
0
    def save_svg_and_png(self, kwargs):
        """ Save png out of the svg version of the chart
        """
        if not IFolderish.providedBy(self.context):
            return _("Can't save png chart on a non-folderish object !")
        form = getattr(self.request, 'form', {})
        kwargs.update(form)
        filename = kwargs.get('filename', 'img')
        chart_url = self.context.absolute_url() + "#" + "tab-" + filename
        svg_filename = filename + ".svg"
        filename += ".png"
        sp = self.siteProperties
        qr_size = sp.get('googlechart.qrcode_size', '70')
        object_ids = self.context.objectIds()
        if qr_size == '0':
            qr_size = '70'
        qr_url = (u"https://chart.apis.google.com"
                  "/chart?cht=qr&chld=H%sC0&chs=%sx%s&chl=%s" %
                  ("%7", qr_size, qr_size, urllib2.quote(chart_url)))
        self.request.form['qr_url'] = qr_url
        svg_data = kwargs.get('svg', '')
        if not svg_data:
            return _("Success")
        new_svg = False
        if svg_filename not in object_ids:
            new_svg = True
            svg_filename = self.context.invokeFactory('File', id=svg_filename)
        svg_obj = self.context._getOb(svg_filename)
        svg_file_field = svg_obj.getField('file')
        svg_field_data = svg_file_field.getRaw(svg_obj).getIterator().read()
        if svg_field_data and svg_data == svg_field_data:
            return _("Success")
        elif svg_field_data:
            # 21894 svg_data from the form and the data saved within the current
            # svg files sometimes has the clipPath id number changed, otherwise
            # the files are identical in which case we no longer need to perform
            # any svg and image generation
            pattern = re.compile(r'_ABSTRACT_RENDERER_ID_\d+')
            # 79908 check if we have a result for pattern search
            pattern_match = pattern.search(svg_data)
            if pattern_match:
                svg_data_match = pattern_match.group()
                svg_field_data_matched = pattern.sub(svg_data_match,
                                                     svg_field_data)
                if svg_data == svg_field_data_matched:
                    return _("Success")
        # create image from the current svg
        img = super(SavePNGChart, self).__call__()
        # 79908 check if img return has PNG within the string
        # as img can contain ERROR message in case of an error
        # which means the image will contain a string instead of actual
        # image data
        if not img or img and 'PNG' not in img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")
        new_file = False
        if filename not in object_ids:
            new_file = True
            filename = self.context.invokeFactory('Image', id=filename)
        img_obj = self.context._getOb(filename)
        if new_file:
            img_obj.setExcludeFromNav(True)
        image_field = img_obj.getField('image')
        image_field.getMutator(img_obj)(img)
        if new_svg:
            svg_obj.setExcludeFromNav(True)
        svg_file_field.getMutator(svg_obj)(svg_data)

        wftool = getToolByName(svg_obj, "portal_workflow")
        state = wftool.getInfoFor(svg_obj, 'review_state', None)
        if state:
            if state != 'visible':
                workflows = wftool.getWorkflowsFor(svg_obj)
                workflow = workflows[0]
                transitions = workflow.transitions

                # publish
                for transition in wftool.getTransitionsFor(svg_obj):
                    tid = transition.get('id')
                    tob = transitions.get(tid)
                    if not tob:
                        continue

                    if tob.new_state_id != 'published':
                        continue

                    self.request.form['_no_emails_'] = True
                    workflow.doActionFor(svg_obj, tid)
                    break

                # then make it public draft
                for transition in wftool.getTransitionsFor(svg_obj):
                    tid = transition.get('id')
                    tob = transitions.get(tid)
                    if not tob:
                        continue

                    if tob.new_state_id != 'visible':
                        continue

                    workflow.doActionFor(svg_obj, tid)
                    break

                svg_obj.reindexObject()
        if not new_svg:
            notify(InvalidateCacheEvent(svg_obj))
        return _("Success")
Beispiel #17
0
    def __call__(self, **kwargs):
        if not IFolderish.providedBy(self.context):
            return _("Can't save png chart on a non-folderish object !")
        form = getattr(self.request, 'form', {})
        kwargs.update(form)
        filename = kwargs.get('filename', 'img')
        chart_url = self.context.absolute_url() + "#" + "tab-" + filename
        svg_filename = filename + ".svg"
        filename = filename + ".png"
        sp = self.siteProperties
        qr_size = sp.get('googlechart.qrcode_size', '70')
        if qr_size == '0':
            qr_size = '70'
        qr_url = (
            u"http://chart.apis.google.com"
            "/chart?cht=qr&chld=H|0&chs=%sx%s&chl=%s" % (
                qr_size, qr_size, urllib2.quote(chart_url)))
        self.request.form['qr_url'] = qr_url
        img = super(SavePNGChart, self).__call__()

        if not img:
            return _("ERROR: An error occured while exporting your image. "
                     "Please try again later.")

        if filename not in self.context.objectIds():
            filename = self.context.invokeFactory('Image', id=filename)

        obj = self.context._getOb(filename)
        obj.setExcludeFromNav(True)
        obj.getField('image').getMutator(obj)(img)

        svg_data = kwargs.get('svg', '')
        if svg_data:
            if svg_filename not in self.context.objectIds():
                svg_filename = self.context.invokeFactory('File',
                                                          id=svg_filename)
            svg_obj = self.context._getOb(svg_filename)
            svg_obj.setExcludeFromNav(True)
            svg_obj.getField('file').getMutator(svg_obj)(kwargs.get('svg', ''))

            wftool = getToolByName(svg_obj, "portal_workflow")
            workflows = wftool.getWorkflowsFor(svg_obj)
            if len(workflows) > 0:
                workflow = workflows[0]
                transitions = workflow.transitions
                state = wftool.getInfoFor(svg_obj, 'review_state')

                if state != 'visible':
                    available_transitions = [transitions[i['id']] for i in
                                            wftool.getTransitionsFor(svg_obj)]

                    to_do = [k for k in available_transitions
                             if k.new_state_id == 'published']

                    for item in to_do:
                        workflow.doActionFor(svg_obj, item.id)
                        break

                    # then make it public draft
                    available_transitions = [transitions[i['id']] for i in
                                            wftool.getTransitionsFor(svg_obj)]

                    to_do = [k for k in available_transitions
                             if k.new_state_id == 'visible']

                    for item in to_do:
                        workflow.doActionFor(svg_obj, item.id)
                        break

                svg_obj.reindexObject()
                notify(ObjectModifiedEvent(svg_obj))

        return _("Success")