Commit cfcf1155 authored by Jérome Perrin's avatar Jérome Perrin

push and pop preferences like selections.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3723 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 21404671
...@@ -26,13 +26,11 @@ ...@@ -26,13 +26,11 @@
# #
############################################################################## ##############################################################################
from copy import copy from Globals import InitializeClass, DTMLFile, get_request
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass, PersistentMapping, DTMLFile, get_request
from AccessControl import Unauthorized, getSecurityManager, ClassSecurityInfo
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
from Products.Formulator.DummyField import fields from Products.Formulator.DummyField import fields
from Products.Formulator.Form import Form, BasicForm, ZMIForm from Products.Formulator.Form import ZMIForm
from urllib import quote from urllib import quote
from Products.ERP5Type import PropertySheet from Products.ERP5Type import PropertySheet
...@@ -88,6 +86,7 @@ class ERP5Report(ERP5Form): ...@@ -88,6 +86,7 @@ class ERP5Report(ERP5Form):
- Display the transactions of each vendor (one form with listbox) - Display the transactions of each vendor (one form with listbox)
""" """
meta_type = "ERP5 Report" meta_type = "ERP5 Report"
icon = "www/Form.png" icon = "www/Form.png"
...@@ -126,7 +125,6 @@ class ERP5Report(ERP5Form): ...@@ -126,7 +125,6 @@ class ERP5Report(ERP5Form):
# Proxy method to PageTemplate # Proxy method to PageTemplate
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
self._v_relation_field_index = 0 # We initialize here an index which is used to generate different method ids for every field
if not kwargs.has_key('args'): if not kwargs.has_key('args'):
kwargs['args'] = args kwargs['args'] = args
form = self form = self
...@@ -179,15 +177,16 @@ def manage_add_report(self, id, title="", unicode_mode=0, REQUEST=None): ...@@ -179,15 +177,16 @@ def manage_add_report(self, id, title="", unicode_mode=0, REQUEST=None):
class ReportSection: class ReportSection:
meta_type = "ReportSection" meta_type = "ReportSection"
security = ClassSecurityInfo() security = ClassSecurityInfo()
#security.declareObjectPublic()
param_dict = {} param_dict = {}
def __init__(self, path='', form_id='view', def __init__(self, path='', form_id='view',
title=None, translated_title=None, level=1, title=None, translated_title=None, level=1,
selection_name=None, selection_params=None, listbox_display_mode=None, selection_name=None, selection_params=None,
selection_columns=None, selection_sort_order=None, listbox_display_mode=None, selection_columns=None,
selection_report_path=None, selection_report_list=None) : selection_sort_order=None,
selection_report_path=None, selection_report_list=None,
preferences = None ) :
""" """
Initialize the line and set the default values Initialize the line and set the default values
Selected columns must be defined in parameter of listbox.render... Selected columns must be defined in parameter of listbox.render...
...@@ -212,6 +211,10 @@ class ReportSection: ...@@ -212,6 +211,10 @@ class ReportSection:
self.saved_selections = {} self.saved_selections = {}
self.selection_report_path = selection_report_path self.selection_report_path = selection_report_path
self.selection_report_list = selection_report_list self.selection_report_list = selection_report_list
if preferences == None :
preferences = {}
self.preferences = preferences
self.saved_preferences = {}
security.declarePublic('getTitle') security.declarePublic('getTitle')
def getTitle(self): def getTitle(self):
...@@ -286,6 +289,11 @@ class ReportSection: ...@@ -286,6 +289,11 @@ class ReportSection:
portal_selections.setSelectionSortOrder(selection_name, self.selection_sort_order, portal_selections.setSelectionSortOrder(selection_name, self.selection_sort_order,
REQUEST=REQUEST) REQUEST=REQUEST)
portal_pref = context.getPortalObject().portal_preferences
for pref, value in self.preferences.items() :
self.saved_preferences[pref] = portal_pref.getPreference(pref)
portal_pref.setPreference(pref, value)
security.declarePublic('popReport') security.declarePublic('popReport')
def popReport(self, context): def popReport(self, context):
REQUEST = get_request() REQUEST = get_request()
...@@ -333,6 +341,8 @@ class ReportSection: ...@@ -333,6 +341,8 @@ class ReportSection:
self.saved_selections[selection_name]['sort_order'], self.saved_selections[selection_name]['sort_order'],
REQUEST=REQUEST) REQUEST=REQUEST)
for pref, value in self.saved_preferences.items() :
context.getPortalObject().portal_preferences.setPreference(pref, value)
InitializeClass(ReportSection) InitializeClass(ReportSection)
allow_class(ReportSection) allow_class(ReportSection)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment