From 6ca93542b7d2195c4e29b54996312589184586c2 Mon Sep 17 00:00:00 2001 From: Zoltan Szabo Date: Wed, 14 Nov 2012 15:23:07 +0200 Subject: [PATCH] Refs #10019; On saving a chart, copy the generic chart image in the visualization --- docs/HISTORY.txt | 2 ++ eea/app/visualization/views/edit.py | 10 ++++++++++ eea/app/visualization/views/view.py | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index 9bbbd04..fed45ed 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -3,6 +3,8 @@ Changelog 6.2-dev - (unreleased) ---------------------- +* Feature: On saving a chart, copy the generic chart image in the visualization + [szabozo0 refs #10019] * Change: Added a common.js and common.css in order to reuse common components [voineali refs #9610] diff --git a/eea/app/visualization/views/edit.py b/eea/app/visualization/views/edit.py index df9eba7..8062249 100644 --- a/eea/app/visualization/views/edit.py +++ b/eea/app/visualization/views/edit.py @@ -17,6 +17,7 @@ class EditForm(SubPageForm): """ form_fields = None + previewname = None def __init__(self, context, request): """ EditForm init @@ -50,6 +51,15 @@ def save(self, saction, data): mutator = queryAdapter(self.context, IVisualizationConfig) mutator.edit_view(self.prefix, **data) + if self.previewname: + if not self.context.get(self.previewname, None): + img = self.context.restrictedTraverse( + "++resource++" + self.previewname) + self.context.invokeFactory('Image', + id=self.previewname, + title=self.previewname, + image=img.GET()) + name = saction.__name__.encode('utf-8') value = self.request.form.get(name, '') if value == 'ajax': diff --git a/eea/app/visualization/views/view.py b/eea/app/visualization/views/view.py index df8611e..0625587 100644 --- a/eea/app/visualization/views/view.py +++ b/eea/app/visualization/views/view.py @@ -34,7 +34,7 @@ def tabs(self): 'css': tabname, 'tabname': tabname, 'fallback-image': self.context.absolute_url() + \ - "/++resource++" + self.__name__ + ".preview.png" + "/" + self.__name__ + ".preview.png" }, ]