Commit 37b1c21f authored by Rafael Monnerat's avatar Rafael Monnerat

Planning Box was completly refactored. Please update your business

templates in order to make it works.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18275 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7473d9ef
This diff is collapsed.
...@@ -664,8 +664,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -664,8 +664,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
return self.checkAll(list_selection_name, uids, REQUEST=REQUEST, query_string=query_string) return self.checkAll(list_selection_name, uids, REQUEST=REQUEST, query_string=query_string)
# PlanningBox related methods # PlanningBox related methods
security.declareProtected(ERP5Permissions.View, 'setZoomLevel') security.declareProtected(ERP5Permissions.View, 'setLanePath')
def setZoomLevel(self, uids=None, REQUEST=None, form_id=None, def setLanePath(self, uids=None, REQUEST=None, form_id=None,
query_string=None): query_string=None):
""" """
Set graphic zoom level in PlanningBox Set graphic zoom level in PlanningBox
...@@ -677,62 +677,24 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -677,62 +677,24 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST) selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None: if selection is not None:
params = selection.getParams() params = selection.getParams()
zoom_level = request.form.get('zoom_level', None) lane_path = request.form.get('lane_path', None)
if zoom_level is None: if lane_path is None:
# If zoom_level is not defined try to # If lane_path is not defined try to
# use the last one from params # use the last one from params
zoom_level = params.get('zoom_level', 1) lane_path = params.get('lane_path',1)
bound_start = request.form.get('bound_start', None)
# for keep compatibility with the old zoom if bound_start is not None:
zoom_start = request.form.get('zoom_start',0) params['bound_start'] = bound_start
if zoom_level <= zoom_start: params['lane_path'] = lane_path
zoom_start = max(int(float(zoom_level)),1) - 1 params['zoom_variation'] = 0
params['zoom_start'] = zoom_start
# XXX URL currently pass string parameter and not int
# This is a dirty fix!
# It should be fixed by cleaning the date zoom level
# in a generic way
zoom_level = int(zoom_level)
zoom_begin = request.form.get('zoom_begin', None)
#zoom_end = request.form.get('zoom_end', None)
zoom_date_start = request.form.get('zoom_date_start', None)
if zoom_date_start is not None:
zoom_begin = zoom_date_start
if zoom_begin is None:
zoom_begin = params.get('zoom_begin', None)
params['zoom_level'] = zoom_level
# Calculating New zoom Dates Range.
validate_method = getattr(self, 'planning_validate_date_list', None)
date_range = validate_method(zoom_begin,zoom_level)
params['from_date'] = params['zoom_begin'] = date_range[0]
params['to_date'] = params['zoom_end'] = date_range[1]
selection.edit(params=params) selection.edit(params=params)
if REQUEST is not None: if REQUEST is not None:
return self._redirectToOriginalForm(REQUEST=REQUEST, return self._redirectToOriginalForm(REQUEST=REQUEST,
form_id=form_id, form_id=form_id,
query_string=query_string) query_string=query_string)
security.declareProtected(ERP5Permissions.View, 'setZoom') security.declareProtected(ERP5Permissions.View, 'nextLanePage')
def setZoom(self, uids=None, REQUEST=None, form_id=None, query_string=None): def nextLanePage(self, uids=None, REQUEST=None, form_id=None, query_string=None):
"""
Set graphic zoom in PlanningBox
"""
if uids is None: uids = []
request = REQUEST
selection_name=request.list_selection_name
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None:
params = selection.getParams()
zoom_start = request.form.get('zoom_start',0)
params['zoom_start'] = zoom_start
selection.edit(params=params)
if REQUEST is not None:
return self._redirectToOriginalForm(REQUEST=REQUEST, form_id=form_id,
query_string=query_string)
security.declareProtected(ERP5Permissions.View, 'nextZoom')
def nextZoom(self, uids=None, REQUEST=None, form_id=None, query_string=None):
""" """
Set next graphic zoom start in PlanningBox Set next graphic zoom start in PlanningBox
""" """
...@@ -743,28 +705,15 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -743,28 +705,15 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST) selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None: if selection is not None:
params = selection.getParams() params = selection.getParams()
zoom_level = params.get('zoom_level', 1) params['bound_variation'] = 1
zoom_variation = + 1
zoom_begin = request.form.get('zoom_begin', None)
# for keep the compatibility
zoom_start = params.get('zoom_start',0)
params['zoom_start'] = int(zoom_start) + 1
if zoom_begin is None:
zoom_begin = params.get('zoom_begin', None)
validate_method = getattr(self, 'planning_validate_date_list', None)
date_range = validate_method(zoom_begin,zoom_level,zoom_variation)
params['zoom_begin'] = params['from_date'] = date_range[0]
params['zoom_end'] = params['to_date'] = date_range[1]
selection.edit(params=params) selection.edit(params=params)
if REQUEST is not None: if REQUEST is not None:
return self._redirectToOriginalForm(REQUEST=REQUEST, return self._redirectToOriginalForm(REQUEST=REQUEST,
form_id=form_id, form_id=form_id,
query_string=query_string) query_string=query_string)
security.declareProtected(ERP5Permissions.View, 'previousZoom') security.declareProtected(ERP5Permissions.View, 'previousLanePage')
def previousZoom(self, uids=None, REQUEST=None, form_id=None, query_string=None): def previousLanePage(self, uids=None, REQUEST=None, form_id=None, query_string=None):
""" """
Set previous graphic zoom in PlanningBox Set previous graphic zoom in PlanningBox
""" """
...@@ -775,20 +724,7 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -775,20 +724,7 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST) selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None: if selection is not None:
params = selection.getParams() params = selection.getParams()
zoom_level = params.get('zoom_level', 1) params['bound_variation'] = -1
zoom_variation = -1
zoom_begin = request.form.get('zoom_begin', None)
# for keep the compatibility
zoom_start = params.get('zoom_start',0)
params['zoom_start'] = int(zoom_start) - 1
if zoom_begin is None:
zoom_begin = params.get('zoom_begin', None)
validate_method = getattr(self, 'planning_validate_date_list', None)
date_range = validate_method(zoom_begin,zoom_level,zoom_variation)
params['zoom_begin'] = params['from_date'] = date_range[0]
params['zoom_end'] = params['to_date'] = date_range[1]
selection.edit(params=params) selection.edit(params=params)
if REQUEST is not None: if REQUEST is not None:
return self._redirectToOriginalForm(REQUEST=REQUEST, return self._redirectToOriginalForm(REQUEST=REQUEST,
......
...@@ -108,10 +108,10 @@ class TestPlanningBox(ERP5TypeTestCase): ...@@ -108,10 +108,10 @@ class TestPlanningBox(ERP5TypeTestCase):
def stepCheckPlanning(self, sequence = None, sequence_list = None, **kw): def stepCheckPlanning(self, sequence = None, sequence_list = None, **kw):
planning = sequence.get('planning') planning = sequence.get('planning')
self.assertEquals(planning.calendar_view, 0) self.assertEquals(planning.vertical_view, 0)
self.assertEquals(len(planning.content), 1) self.assertEquals(len(planning.content), 1)
bloc = planning.content[0] bloc = planning.content[0]
self.assertEquals(bloc.name , 'Group_1_Activity_1_Block_1') self.assertEquals(bloc.name , 'group_1_activity_1_block_1')
self.assertEquals(bloc.title , 'Title 0') self.assertEquals(bloc.title , 'Title 0')
for info in bloc.info.values(): for info in bloc.info.values():
self.assertEquals(info.info,'Title 0') self.assertEquals(info.info,'Title 0')
...@@ -129,7 +129,7 @@ class TestPlanningBox(ERP5TypeTestCase): ...@@ -129,7 +129,7 @@ class TestPlanningBox(ERP5TypeTestCase):
basic = sequence.get('basic') basic = sequence.get('basic')
self.assertEquals(len(basic.report_groups), 1) self.assertEquals(len(basic.report_groups), 1)
# Note that this test use the use_date_zoom enabled. # Note that this test use the use_date_zoom enabled.
sec_axis_info = basic.getSecondaryAxisInfo() sec_axis_info = basic.getLaneAxisInfo()
date = DateTime() date = DateTime()
today = DateTime('%s/%s/%s' % (date.year(),date.month(),date.day())) today = DateTime('%s/%s/%s' % (date.year(),date.month(),date.day()))
self.assertEquals(sec_axis_info['zoom_begin'], today) self.assertEquals(sec_axis_info['zoom_begin'], today)
......
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