Commit 7cacc761 authored by Romain Courteaud's avatar Romain Courteaud

Planning box can now display a background layer of blocks.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15304 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 96321426
...@@ -655,8 +655,11 @@ class PlanningBoxWidget(Widget.Widget): ...@@ -655,8 +655,11 @@ class PlanningBoxWidget(Widget.Widget):
# axis position # axis position
'y_axis_position', 'x_axis_position', 'y_axis_position', 'x_axis_position',
'report_root_list', 'selection_name', 'report_root_list', 'selection_name',
# Main List Method
'portal_types', 'sort', 'portal_types', 'sort',
'list_method', 'list_method',
# Second Layer Properties
'second_layer_list_method',
# method used to get title of each line # method used to get title of each line
'title_line', 'title_line',
# specific block properties # specific block properties
...@@ -816,6 +819,13 @@ class PlanningBoxWidget(Widget.Widget): ...@@ -816,6 +819,13 @@ class PlanningBoxWidget(Widget.Widget):
default='', default='',
required=0) required=0)
second_layer_list_method = fields.MethodField('second_layer_list_method',
title='Secondary Layer List Method',
description="Method to use to list background objects",
default='',
required=0)
title_line = fields.StringField('title_line', title_line = fields.StringField('title_line',
title="Specific method which fetches the title of each line", title="Specific method which fetches the title of each line",
description="Method for inserting title in line", description="Method for inserting title in line",
...@@ -1003,6 +1013,7 @@ class PlanningBoxWidget(Widget.Widget): ...@@ -1003,6 +1013,7 @@ class PlanningBoxWidget(Widget.Widget):
# getting form # getting form
form = field.aq_parent form = field.aq_parent
list_method = field.get_value('list_method') list_method = field.get_value('list_method')
sec_layer_list_method = field.get_value('second_layer_list_method')
title_line = field.get_value('title_line') title_line = field.get_value('title_line')
# list of domain # list of domain
report_root_list = field.get_value('report_root_list') report_root_list = field.get_value('report_root_list')
...@@ -1029,7 +1040,9 @@ class PlanningBoxWidget(Widget.Widget): ...@@ -1029,7 +1040,9 @@ class PlanningBoxWidget(Widget.Widget):
# creating BasicStructure instance (and initializing its internal values) # creating BasicStructure instance (and initializing its internal values)
basic = BasicStructure(context=context, basic = BasicStructure(context=context,
form=form, field=field, form=form, field=field,
REQUEST=REQUEST, list_method=list_method, REQUEST=REQUEST,
list_method=list_method,
sec_layer_list_method=sec_layer_list_method,
selection=selection, params=params, selection=selection, params=params,
selection_name=selection_name, selection_name=selection_name,
title_line=title_line, title_line=title_line,
...@@ -1070,7 +1083,7 @@ class BasicStructure: ...@@ -1070,7 +1083,7 @@ class BasicStructure:
def __init__ (self, context='', form='', field='', REQUEST='', list_method='', def __init__ (self, context='', form='', field='', REQUEST='', list_method='',
selection=None, params = '', selection_name='', selection=None, params = '', selection_name='',
report_root_list='', title_line='', portal_types='', report_root_list='', title_line='', portal_types='',
sort=None, list_error=None): sec_layer_list_method=None, sort=None, list_error=None):
""" """
Init main internal parameters Init main internal parameters
""" """
...@@ -1082,6 +1095,7 @@ class BasicStructure: ...@@ -1082,6 +1095,7 @@ class BasicStructure:
self.selection = selection self.selection = selection
self.params = params self.params = params
self.list_method = list_method self.list_method = list_method
self.sec_layer_list_method = sec_layer_list_method
self.title_line = title_line self.title_line = title_line
self.selection_name = selection_name self.selection_name = selection_name
self.report_root_list = report_root_list self.report_root_list = report_root_list
...@@ -1138,6 +1152,11 @@ class BasicStructure: ...@@ -1138,6 +1152,11 @@ class BasicStructure:
portal_categories = getattr(self.form,'portal_categories',None) portal_categories = getattr(self.form,'portal_categories',None)
portal_domains = getattr(self.form,'portal_domains',None) portal_domains = getattr(self.form,'portal_domains',None)
if getattr(self.sec_layer_list_method, 'method_name', None) is not None:
self.sec_layer_list_method = getattr(
self.context,
self.sec_layer_list_method.method_name)
################################################## ##################################################
############### BUILDING QUERY ################### ############### BUILDING QUERY ###################
################################################## ##################################################
...@@ -1150,7 +1169,7 @@ class BasicStructure: ...@@ -1150,7 +1169,7 @@ class BasicStructure:
# names. # names.
if 'select_expression' in kw: if 'select_expression' in kw:
del kw['select_expression'] del kw['select_expression']
if hasattr(self.list_method, 'method_name'): if getattr(self.list_method, 'method_name', None) is not None:
if self.list_method.method_name == 'ObjectValues': if self.list_method.method_name == 'ObjectValues':
# list_method is available # list_method is available
self.list_method = self.context.objectValues self.list_method = self.context.objectValues
...@@ -1232,6 +1251,7 @@ class BasicStructure: ...@@ -1232,6 +1251,7 @@ class BasicStructure:
is_report_opened=is_report_opened, is_report_opened=is_report_opened,
sort_on=self.selection.sort_on, sort_on=self.selection.sort_on,
form_id=self.form.id) form_id=self.form.id)
if report_tree_list == []: if report_tree_list == []:
raise PlanningBoxError, "Report tree list is empty on %s" % \ raise PlanningBoxError, "Report tree list is empty on %s" % \
self.field.absolute_url() self.field.absolute_url()
...@@ -1313,33 +1333,51 @@ class BasicStructure: ...@@ -1313,33 +1333,51 @@ class BasicStructure:
raise PlanningBoxError, "No list method found on %s" % \ raise PlanningBoxError, "No list method found on %s" % \
self.field.absolute_url() self.field.absolute_url()
# Defining the Secondary Layer Object List
if self.sec_layer_list_method not in (None,''):
sec_layer_object_list = self.selection(
method=self.sec_layer_list_method,
context=self.context,
REQUEST=self.REQUEST)
else:
sec_layer_object_list = []
# recovering exeption_uid_list # recovering exeption_uid_list
exception_uid_list = object_tree_line.getExceptionUidList() exception_uid_list = object_tree_line.getExceptionUidList()
# XXX filter the object to the right domain.
# Can be improved in future.
domain_obj = object_tree_line.getObject() domain_obj = object_tree_line.getObject()
new_object_list = [] new_object_list = []
sec_new_object_list = []
if domain_obj.getPortalType() == 'Domain': if domain_obj.getPortalType() == 'Domain':
category_obj = domain_obj.getMembershipCriterionCategory() category_obj = domain_obj.getMembershipCriterionCategory()
base_category_list = domain_obj.getMembershipCriterionBaseCategoryList() for bc in domain_obj.getMembershipCriterionBaseCategoryList():
for bc in base_category_list:
if (category_obj is not None) and (bc is not None): if (category_obj is not None) and (bc is not None):
category_value = category_obj.getRelativeUrl() category_value = category_obj.getRelativeUrl()
for s_obj in object_list: new_object_list.extend([ s_obj for s_obj in object_list \
if s_obj._getDefaultAcquiredCategoryMembership(bc) == category_value: if s_obj._getDefaultAcquiredCategoryMembership(bc) == category_value])
new_object_list.append(s_obj)
sec_new_object_list.extend([ s_obj for s_obj in sec_layer_object_list \
if s_obj._getDefaultAcquiredCategoryMembership(bc) == category_value])
object_list = new_object_list object_list = new_object_list
sec_layer_object_list = sec_new_object_list
if exception_uid_list not in ([],None) : if exception_uid_list not in ([],None) :
# Filter folders if parent tree : # Filter folders if parent tree :
# build new object_list for current line # build new object_list for current line
# (list of relative elements) # (list of relative elements)
new_object_list = [] new_object_list = [s_obj for s_obj in object_list \
for selected_object in object_list: if s_obj.getUid() not in exception_uid_list]
if selected_object.getUid() not in exception_uid_list: sec_new_object_list = [s_obj for s_obj in object_list \
new_object_list.append(selected_object) if s_obj.getUid() not in exception_uid_list]
sec_layer_object_list = sec_new_object_list
object_list = new_object_list object_list = new_object_list
self.sec_layer_uid_list = [obj.getUid() for obj in sec_layer_object_list]
# The order is important
sec_layer_object_list.extend(object_list)
object_list = sec_layer_object_list
if not object_tree_line.getIsPureSummary(): if not object_tree_line.getIsPureSummary():
# Object is not pure summary # Object is not pure summary
if show_stat: if show_stat:
...@@ -1735,7 +1773,8 @@ class BasicStructure: ...@@ -1735,7 +1773,8 @@ class BasicStructure:
is_pure_summary=is_pure_summary, is_pure_summary=is_pure_summary,
secondary_axis_start = group_start, secondary_axis_start = group_start,
secondary_axis_stop = group_stop, secondary_axis_stop = group_stop,
property_dict = property_dict) property_dict = property_dict,
sec_layer_uid_list=self.sec_layer_uid_list)
if object_list not in [None, []]: if object_list not in [None, []]:
child_group.setBasicActivities(object_list,self.list_error, child_group.setBasicActivities(object_list,self.list_error,
...@@ -1765,7 +1804,8 @@ class BasicGroup: ...@@ -1765,7 +1804,8 @@ class BasicGroup:
def __init__ (self, title='', name='',url='', constraints='', depth=0, def __init__ (self, title='', name='',url='', constraints='', depth=0,
position=0, field = None, object = None, is_open=0, position=0, field = None, object = None, is_open=0,
is_pure_summary=1, secondary_axis_start=None, is_pure_summary=1, secondary_axis_start=None,
secondary_axis_stop=None, property_dict = {}): secondary_axis_stop=None, sec_layer_uid_list=[],
property_dict = {}):
self.title = title self.title = title
self.name = name self.name = name
self.url = url self.url = url
...@@ -1785,7 +1825,7 @@ class BasicGroup: ...@@ -1785,7 +1825,7 @@ class BasicGroup:
# property_dict holds all information about the current axis_group # property_dict holds all information about the current axis_group
# type of group, stat, etc. # type of group, stat, etc.
self.property_dict = property_dict self.property_dict = property_dict
self.sec_layer_uid_list = sec_layer_uid_list
def setBasicActivities(self,activity_list, list_error,secondary_axis_info): def setBasicActivities(self,activity_list, list_error,secondary_axis_info):
""" """
...@@ -1908,7 +1948,7 @@ class BasicGroup: ...@@ -1908,7 +1948,7 @@ class BasicGroup:
info_botleft_method = getattr(activity_content,info_botleft,None) info_botleft_method = getattr(activity_content,info_botleft,None)
info_botright_method = \ info_botright_method = \
getattr(activity_content,info_botright,None) getattr(activity_content,info_botright,None)
if obj.getUid() not in self.sec_layer_uid_list:
# if value recovered is not null, then updating # if value recovered is not null, then updating
if info_center_method is not None: if info_center_method is not None:
info['info_center']=str(info_center_method()) info['info_center']=str(info_center_method())
...@@ -1920,6 +1960,12 @@ class BasicGroup: ...@@ -1920,6 +1960,12 @@ class BasicGroup:
info['info_botleft'] =str(info_botleft_method()) info['info_botleft'] =str(info_botleft_method())
if info_botright_method is not None: if info_botright_method is not None:
info['info_botright']=str(info_botright_method()) info['info_botright']=str(info_botright_method())
else:
info['info_center'] = ''
info['info_topright'] = ''
info['info_topleft'] = ''
info['info_botleft'] = ''
info['info_botright'] = ''
title = info['info_center'] title = info['info_center']
color_script = getattr(activity_content.getObject(), color_script = getattr(activity_content.getObject(),
...@@ -2256,7 +2302,6 @@ class PlanningStructure: ...@@ -2256,7 +2302,6 @@ class PlanningStructure:
complete axis informations (and more precisely axis position objects) thanks complete axis informations (and more precisely axis position objects) thanks
to the actual planning structure to the actual planning structure
""" """
# processing main axis # processing main axis
for axis_group_element in self.main_axis.axis_group: for axis_group_element in self.main_axis.axis_group:
position_main = axis_group_element.position_main position_main = axis_group_element.position_main
...@@ -2365,7 +2410,8 @@ class PlanningStructure: ...@@ -2365,7 +2410,8 @@ class PlanningStructure:
calendar_view=self.calendar_view, calendar_view=self.calendar_view,
property_dict=basic_group_object.property_dict) property_dict=basic_group_object.property_dict)
# adding activity to the current group # adding activity to the current group
axis_group.addActivity(activity,axis_element_already_present) axis_group.addActivity(activity, axis_element_already_present,
basic_structure)
else: else:
# case group is stat group. Using special method that prevent # case group is stat group. Using special method that prevent
# from generating more than 1 axis element and divide tasks size if # from generating more than 1 axis element and divide tasks size if
...@@ -2926,7 +2972,8 @@ class AxisGroup: ...@@ -2926,7 +2972,8 @@ class AxisGroup:
self.tooltip = info_title.info self.tooltip = info_title.info
def addActivity(self, activity=None, axis_element_already_insered= 0): def addActivity(self, activity=None, axis_element_already_insered= 0,
basic_structure=None):
""" """
Procedure that permits to add activity to the corresponding AxisElement in Procedure that permits to add activity to the corresponding AxisElement in
an AxisGroup. This can create new Axis Element in the actual AxisGroup if an AxisGroup. This can create new Axis Element in the actual AxisGroup if
...@@ -2944,13 +2991,14 @@ class AxisGroup: ...@@ -2944,13 +2991,14 @@ class AxisGroup:
# recovering all activity properties of the actual axis_element and # recovering all activity properties of the actual axis_element and
# iterating through them to check if one of them crosses the new one # iterating through them to check if one of them crosses the new one
for activity_statement in axis_element.activity_list: for activity_statement in axis_element.activity_list:
if activity_statement.isValidPosition(activity.secondary_axis_begin, if activity_statement.isValidPosition(activity.secondary_axis_begin,
activity.secondary_axis_end) != 0: activity.secondary_axis_end) != 0:
# isValidPosition returned 1 or 2, this means the activity already # isValidPosition returned 1 or 2, this means the activity already
# present does prevent from adding the new activity as there is # present does prevent from adding the new activity as there is
# coverage on the current axis_element. # coverage on the current axis_element.
# stop iterating actual axis_element and try with the next one # stop iterating actual axis_element and try with the next one
if activity_statement.object.getUid() not in \
basic_structure.sec_layer_uid_list:
can_add = 0 can_add = 0
break break
......
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