Commit 85fab151 authored by Thomas Bernard's avatar Thomas Bernard

2006-06-30 Thomas

* Added PlanningBox 3rd part scripts, including stats and axis generation.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8239 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4e5fe73e
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# Return first listbox in a form that is enabled and not hidden\n
# Christophe Dumez <christophe@nexedi.com>\n
# This script should be used to detect a listbox without having to name it "listbox"\n
\n
if form is None:\n
form=context\n
\n
if form.meta_type != \'ERP5 Form\':\n
return None\n
\n
# we start with \'bottom\' because most of the time\n
# the listbox is there.\n
for group in (\'bottom\', \'center\', \'left\', \'right\'):\n
for field in form.get_fields_in_group(group):\n
if field.meta_type == \'PlanningBox\' and not(field[\'hidden\']) and field[\'enabled\']:\n
return field\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_core/ERP5Site_getPlanningBox</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>form</string>
<string>None</string>
<string>context</string>
<string>_getattr_</string>
<string>_getiter_</string>
<string>group</string>
<string>field</string>
<string>_getitem_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getPlanningBox</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
XXX temporary function to recover statistics when needed\n
=> will be put in an external script.\n
recover a list with temporary objects we want to apply stats on.\n
(can be object itself, list of direct sons, list of all sons using\n
recursive method, etc.)\n
Then take this special list of objects and return a list of special\n
temp_objects to display as blocks \'as they are\'\n
"""\n
from Products.ERP5Type.Document import newTempBase\n
\n
\n
# first recovering methods to apply on tasks\n
start_property_id = field.get_value(\'x_start_bloc\')\n
stop_property_id= field.get_value(\'x_stop_bloc\')\n
size_property_id = field.get_value(\'y_size_block\')\n
\n
\n
\n
###########################################################\n
########### CREATING LIST OF TEMP STAT OBJECTS ############\n
###########################################################\n
# find a way to get all related objects with their sub-objects\n
# this list of objects must be stored in a list\n
# for now considering applying statistics on object_list\n
# XXX bug : can not apply getExceptionUidList() method on object_tree_line.\n
# <<unauthorized access>>\n
#selection.edit(exception_uid_list= object_tree_line.getExceptionUidList())\n
input_object_list = selection(method = list_method,context= selection_context,\n
REQUEST=REQUEST)\n
\n
temp_object_list = []\n
temp_object_id = 0\n
# now applying statictic rule.\n
# for now statistic rules are static\n
\n
\n
for input_object in input_object_list:\n
# recovering input_object attributes\n
block_begin = input_object.getObject().getProperty(start_property_id,None)\n
block_end = input_object.getObject().getProperty(stop_property_id,None)\n
block_size = input_object.getObject().getProperty(size_property_id,None)\n
if block_begin != None and block_end != None:\n
# do not create stat on non completed objects.\n
# prevent bug while size property is not defined on the object\n
if block_size == None: block_size = block_end - block_begin\n
#updating block_size value\n
block_size = float(block_size) / (block_end - block_begin)\n
# creating new object\n
temp_object = newTempBase(context.getPortalObject(),temp_object_id)\n
# editing object with new values\n
temp_object.setProperty(start_property_id,block_begin)\n
temp_object.setProperty(stop_property_id, block_end)\n
temp_object.setProperty(size_property_id, block_size)\n
# adding new object to list\n
temp_object_list.append(temp_object)\n
temp_object_id += 1\n
\n
###########################################################\n
################ BUILDING STATS ACTIVITES #################\n
###########################################################\n
\n
# building a special list structure.\n
prop_list = []\n
for temp_stat in temp_object_list:\n
block_begin = temp_stat.getProperty(start_property_id)\n
block_end = temp_stat.getProperty(stop_property_id)\n
block_size = temp_stat.getProperty(size_property_id)\n
\n
prop_list.append([block_begin, block_size])\n
prop_list.append([block_end ,-block_size])\n
\n
\n
# now sorting list to put start & stop in the right order\n
prop_list.sort()\n
\n
# now building new list of temp object with updated properties\n
size = 0\n
temp_stat_object_list = []\n
for index in range(len(prop_list) - 1):\n
# iterating all prop_list elements except the last one\n
current_prop = prop_list[index]\n
size += current_prop[1] # new size is relative to the previous size\n
start = current_prop[0] # current start\n
stop = prop_list[index+1][0] # current stop is the begining of the next block\n
temp_stat_object_id = 0\n
\n
if size > 0:\n
# size is not null\n
# building new tempObject\n
temp_stat_object_id += 1\n
temp_stat_object = newTempBase(context.getPortalObject(),temp_object_id)\n
# editing object with new values\n
temp_stat_object.setProperty(start_property_id,start)\n
temp_stat_object.setProperty(stop_property_id, stop)\n
temp_stat_object.setProperty(size_property_id, size)\n
# adding new object to list\n
temp_stat_object_list.append(temp_stat_object)\n
temp_stat_object_id +=1\n
\n
return temp_stat_object_list\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_core/Planning_commonStats</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>selection=None,list_method=None, selection_context=None, report_tree_list = None, object_tree_line=None, REQUEST=None, field=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>7</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>selection</string>
<string>list_method</string>
<string>selection_context</string>
<string>report_tree_list</string>
<string>object_tree_line</string>
<string>REQUEST</string>
<string>field</string>
<string>Products.ERP5Type.Document</string>
<string>newTempBase</string>
<string>_getattr_</string>
<string>start_property_id</string>
<string>stop_property_id</string>
<string>size_property_id</string>
<string>input_object_list</string>
<string>temp_object_list</string>
<string>temp_object_id</string>
<string>_getiter_</string>
<string>input_object</string>
<string>None</string>
<string>block_begin</string>
<string>block_end</string>
<string>block_size</string>
<string>float</string>
<string>context</string>
<string>temp_object</string>
<string>prop_list</string>
<string>temp_stat</string>
<string>size</string>
<string>temp_stat_object_list</string>
<string>range</string>
<string>len</string>
<string>index</string>
<string>_getitem_</string>
<string>current_prop</string>
<string>start</string>
<string>stop</string>
<string>temp_stat_object_id</string>
<string>temp_stat_object</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
<none/>
<none/>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_commonStats</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# In all cases, return list structure containing tuple of information\n
# 1 tuple == 1 group\n
# tuple is of the form :\n
# [ relative position, title, tooltip, delimiter_type]\n
# with delimiter type in 0,1,2\n
\n
if isinstance(axis_start,DateTime):\n
# testing delimiter_type to apply (day, week, month, year)\n
# from smallest type to biggest\n
type_list = [ [\'year\', 365],\n
[\'6months\',182],\n
[\'3months\', 91],\n
[\'month\', 30],\n
[\'1/2month\',15],\n
[\'week\', 7],\n
[\'3days\', 3],\n
[\'day\', 1],\n
[\'6hours\',0.25]\n
]\n
# default good_type is last one (if nothing else matches)\n
good_type = type_list[-1]\n
for date_type in type_list:\n
# iterating each delimiter_type and testing if it matches the delimitation\n
# number definition\n
if float(axis_stop - axis_start) / date_type[1] >= delimiter_min_number:\n
good_type = date_type\n
break\n
\n
\n
delimiter = 0\n
delimiter_list = []\n
delimiter_list.append([int(axis_start),\'\',axis_start.Day() + \' \' + str(DateTime(axis_start)), 0])\n
\n
\n
#### Hour ###\n
if good_type[0] == \'hour\':\n
pass\n
\n
\n
## 6 Hours ##\n
if good_type[0] == \'6hours\':\n
# recovering first valid date\n
if axis_start.hour() > 18:\n
#need to use the next day\n
current_date = DateTime((axis_start + 1).Date())\n
elif axis_start.hour() == 0:\n
current_date = DateTime(axis_start.Date())\n
else:\n
if axis_start.hour() > 12:\n
hours = 18\n
elif axis_start.hour() > 6:\n
hours = 12\n
else:\n
hours = 6\n
current_date = DateTime(\'%s/%s/%s %s:0:0\' % (str(axis_start.year()),\n
str(axis_start.month()),\n
str(axis_start.day()),\n
hours))\n
while current_date < axis_stop:\n
if current_date.hour() == 0 :\n
delimiter = 2\n
elif current_date.hour() == 12:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
\'%s. %s %s:00\' % (current_date.Day()[:1],\n
str(current_date.day()),\n
str(current_date.hour())),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter])\n
if current_date.hour() == 18:\n
#need to use the next day\n
current_date = DateTime((current_date + 1).Date())\n
else:\n
hours = current_date.hour() + 6\n
current_date = DateTime(\'%s/%s/%s %s:0:0\' % (str(current_date.year()),\n
str(current_date.month()),\n
str(current_date.day()),\n
hours))\n
\n
\n
##### DAY ####\n
if good_type[0] == \'day\':\n
# recovering first date displayed, without time:\n
current_date = DateTime(axis_start.Date()) + 1\n
# first date is used to get list of compliant dates\n
while current_date < axis_stop:\n
if current_date.day() == 1:\n
delimiter = 2\n
elif current_date.day() == 15:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
\'%s/%s\' % (str(current_date.month()),\n
str(current_date.day())),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
# go to next date\n
current_date = current_date + 1\n
\n
\n
\n
\n
##### 3 DAYs ####\n
if good_type[0] == \'3days\':\n
# recovering first date displayed, without time:\n
current_date = DateTime(axis_start.Date()) + 1\n
# first date is used to get list of compliant dates\n
while current_date < axis_stop:\n
if current_date.day() == 1:\n
delimiter = 2\n
elif current_date.day() == 15:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
\'%s/%s\' % (str(current_date.month()),\n
str(current_date.day())),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
# go to next date\n
current_date = current_date + 3\n
\n
\n
\n
#### WEEK ####\n
if good_type[0] == \'week\':\n
current_date = DateTime(axis_start.Date()) + 1\n
#DateTime(str(axis_start.year()) + \'/\' + str(axis_start.month()) + \'/\' + str(axis_start.day() + 1))\n
# current date is any day in the week, moving to the first next Monday\n
while current_date.Day() != \'Monday\':\n
current_date = current_date + 1\n
# getting list of weeks\n
while current_date < axis_stop:\n
delimiter_list.append([int(current_date),\n
str(current_date.month()) + \'/\' + str(current_date.day()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
current_date = current_date + 7\n
\n
\n
\n
#### 1/2MONTH ####\n
if good_type[0] == \'1/2month\':\n
# getting first valid date\n
if axis_start.month() == 12 and axis_start.day() > 15:\n
# need to go to the next year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\' )\n
elif axis_start.day() > 15:\n
# need to go to next month\n
current_date = DateTime(str(axis_start.year()) + \'/\' + str((axis_start.month() +1)) + \'/1\')\n
else:\n
# need to go to next part of current month\n
current_date = DateTime(str(axis_start.year()) + \'/\' + str(axis_start.month()) + \'/15\')\n
# getting list of months\n
while current_date < axis_stop:\n
if current_date.day() == 1:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.month()) + \'/\' + str(current_date.day()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
if current_date.month() == 12 and current_date.day() == 15:\n
# need to go to the next year\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\' )\n
elif current_date.day() == 15:\n
# need to go to next month\n
current_date = DateTime(str(current_date.year()) + \'/\' + str((current_date.month() +1)) + \'/1\')\n
else:\n
# need to go to next year\n
current_date = DateTime(str(current_date.year()) + \'/\' + str((current_date.month())) + \'/15\')\n
\n
\n
#### MONTH ####\n
if good_type[0] == \'month\':\n
# getting first valid date\n
if axis_start.month() == 12:\n
# need to go to the next year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(axis_start.year()) + \'/\' + str((axis_start.month() +1)) + \'/1\')\n
# getting list of months\n
while current_date < axis_stop:\n
if current_date.month() == 1:\n
delimiter = 2\n
elif current_date.month() == 7:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.year()) + \'/\' + str(current_date.month()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
if current_date.month() == 12:\n
# need to go to the next year\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(current_date.year()) + \'/\' + str((current_date.month() +1)) + \'/1\')\n
\n
\n
\n
## 3 MONTHS ##\n
if good_type[0] == \'3months\':\n
# getting first valid date\n
if axis_start.month() > 9:\n
# need to go to the next year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\' )\n
elif axis_start.month() > 6:\n
current_date = DateTime(str(axis_start.year()) + \'/10/1\')\n
elif axis_start.month() > 3:\n
current_date = DateTime(str(axis_start.year()) + \'/7/1\')\n
else:\n
current_date = DateTime(str(axis_start.year()) + \'/4/1\')\n
while current_date < axis_stop:\n
if current_date.month() == 1:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.year()) + \'/\' + str(current_date.month()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
if current_date.month() > 9:\n
# need to go to the next year\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(\'%s/%s/1\' % (str(current_date.year()),\n
str(current_date.month() + 3))))\n
\n
\n
## 6 MONTHS ##\n
if good_type[0] == \'6months\':\n
# getting first valid date\n
if axis_start.month() > 6:\n
# need to go to the next year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(axis_start.year()) + \'/7/1\')\n
while current_date < axis_stop:\n
if current_date.month() == 1:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.year()) + \'/\' + str(current_date.month()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
if current_date.month() > 6:\n
# need to go to the next year\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(current_date.year()) + \'/7/1\')\n
\n
\n
#### YEAR ####\n
if good_type[0] == \'year\':\n
# getting first valid year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\')\n
while current_date < axis_stop:\n
if str(current_date.year())[3:] == 0:\n
delimiter = 2\n
elif str(current_date.year())[3:] == 5:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.year()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\')\n
\n
return delimiter_list\n
\n
\n
else:\n
\n
delimiter_list = []\n
# secondary axis type is integer / float.\n
# building corresponding axis.\n
axis_range = axis_stop - axis_start\n
step = 1.0 / 1000.0\n
good_step = step\n
while step * delimiter_min_number < axis_range:\n
good_step = step\n
step = step * 10\n
\n
\n
# now adding first value\n
delimiter_list.append([axis_start,\'\',str(axis_start),0])\n
\n
# now going to first good step\n
modul = axis_start % good_step\n
if modul == 0:\n
#axis_start is already well placed.\n
current_step = good_step + axis_start\n
else:\n
current_step = good_step + (axis_start - modul)\n
\n
# good step is the last step under axis_range.\n
if good_step >= 1:\n
good_step = int(good_step)\n
current_step = int(current_step)\n
\n
# iterating and adding each value\n
while current_step < axis_stop:\n
delimiter_list.append([current_step,str(current_step),str(current_step),0])\n
current_step += good_step\n
\n
return delimiter_list\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_core/Planning_generateAxis</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>axis_start, axis_stop, delimiter_min_number</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>axis_start</string>
<string>axis_stop</string>
<string>delimiter_min_number</string>
<string>isinstance</string>
<string>DateTime</string>
<string>type_list</string>
<string>_getitem_</string>
<string>good_type</string>
<string>_getiter_</string>
<string>date_type</string>
<string>float</string>
<string>delimiter</string>
<string>delimiter_list</string>
<string>_getattr_</string>
<string>int</string>
<string>str</string>
<string>current_date</string>
<string>hours</string>
<string>axis_range</string>
<string>step</string>
<string>good_step</string>
<string>modul</string>
<string>current_step</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_generateAxis</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# In all cases, return list structure containing tuple of information\n
# 1 tuple == 1 group\n
# tuple is of the form :\n
# [ relative position, title, tooltip, delimiter_type]\n
# with delimiter type in 0,1,2\n
\n
from Products.ERP5Type.Message import Message\n
\n
# ***********************************\n
# specific method for calendar mode\n
# ***********************************\n
# use only with calendar\n
\n
delimiter_list = []\n
if axis_stop:\n
axis_range = float(axis_stop - axis_start)\n
\n
type_list = [ [\'year\', 364],\n
[\'month\', 28],\n
[\'week\', 7],\n
[\'day\', 1]]\n
\n
# default good_type is last one (if nothing else matches)\n
good_type = type_list[-1]\n
for date_type in type_list:\n
# iterating each delimiter_type and testing if it matches the delimitation\n
# number definition\n
if axis_range >= date_type[1]:\n
good_type = date_type\n
break\n
\n
\n
\n
if good_type[0] == \'year\':\n
step = 30.416\n
delimiter = 1\n
step_list = [[0, Message(mesage=\'Jan\')],\n
[1, Message(mesage=\'Feb\')],\n
[2, Message(mesage=\'Mar\')],\n
[3, Message(mesage=\'Apr\')],\n
[4, Message(mesage=\'May\')],\n
[5, Message(mesage=\'Jun\')],\n
[6, Message(mesage=\'Jul\')],\n
[7, Message(mesage=\'Aug\')],\n
[8, Message(mesage=\'Sep\')],\n
[9, Message(mesage=\'Oct\')],\n
[10, Message(mesage=\'Nov\')],\n
[11, Message(mesage=\'Dec\')]]\n
for step_id in step_list:\n
delimiter_list.append([\n
step * step_id[0],\n
step_id[1],\n
step_id[1],\n
delimiter])\n
\n
\n
\n
\n
if good_type[0] == \'month\':\n
step = 1\n
step_id = 0\n
step_list = []\n
delimiter = 1\n
while step_id < axis_range:\n
step_list.append([step_id, str(step_id +1)])\n
step_id += step\n
for step_id in step_list:\n
delimiter_list.append([\n
step_id[0],\n
step_id[1],\n
step_id[1],\n
delimiter])\n
\n
\n
\n
\n
if good_type[0] == \'week\':\n
step = 1\n
delimiter = 1\n
step_list = [[0, Message(mesage=\'Monday\')],\n
[1, Message(mesage=\'Tuesday\')],\n
[2, Message(mesage=\'Wednesday\')],\n
[3, Message(mesage=\'Thursday\')],\n
[4, Message(mesage=\'Friday\')],\n
[5, Message(mesage=\'Saturday\')],\n
[6, Message(mesage=\'Sunday\')]]\n
for step_id in step_list:\n
delimiter_list.append([\n
step * step_id[0],\n
step_id[1],\n
step_id[1],\n
delimiter])\n
\n
\n
\n
return delimiter_list\n
\n
\n
\n
"""\n
delimiter = 0\n
delimiter_list = []\n
delimiter_list.append([int(axis_start),\'\',axis_start.Day() + \' \' + str(DateTime(axis_start)), 0])\n
\n
\n
#### Hour ###\n
if good_type[0] == \'hour\':\n
pass\n
\n
\n
## 6 Hours ##\n
if good_type[0] == \'6hours\':\n
# recovering first valid date\n
if axis_start.hour() > 18:\n
#need to use the next day\n
current_date = DateTime((axis_start + 1).Date())\n
elif axis_start.hour() == 0:\n
current_date = DateTime(axis_start.Date())\n
else:\n
if axis_start.hour() > 12:\n
hours = 18\n
elif axis_start.hour() > 6:\n
hours = 12\n
else:\n
hours = 6\n
current_date = DateTime(\'%s/%s/%s %s:0:0\' % (str(axis_start.year()),\n
str(axis_start.month()),\n
str(axis_start.day()),\n
hours))\n
while current_date < axis_stop:\n
if current_date.hour() == 0 :\n
delimiter = 2\n
elif current_date.hour() == 12:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
\'%s. %s %s:00\' % (current_date.Day()[:1],\n
str(current_date.day()),\n
str(current_date.hour())),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter])\n
if current_date.hour() == 18:\n
#need to use the next day\n
current_date = DateTime((current_date + 1).Date())\n
else:\n
hours = current_date.hour() + 6\n
current_date = DateTime(\'%s/%s/%s %s:0:0\' % (str(current_date.year()),\n
str(current_date.month()),\n
str(current_date.day()),\n
hours))\n
\n
\n
##### DAY ####\n
if good_type[0] == \'day\':\n
# recovering first date displayed, without time:\n
current_date = DateTime(axis_start.Date()) + 1\n
# first date is used to get list of compliant dates\n
while current_date < axis_stop:\n
if current_date.day() == 1:\n
delimiter = 2\n
elif current_date.day() == 15:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
\'%s/%s\' % (str(current_date.month()),\n
str(current_date.day())),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
# go to next date\n
current_date = current_date + 1\n
\n
\n
\n
\n
##### 3 DAYs ####\n
if good_type[0] == \'3days\':\n
# recovering first date displayed, without time:\n
current_date = DateTime(axis_start.Date()) + 1\n
# first date is used to get list of compliant dates\n
while current_date < axis_stop:\n
if current_date.day() == 1:\n
delimiter = 2\n
elif current_date.day() == 15:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
\'%s/%s\' % (str(current_date.month()),\n
str(current_date.day())),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
# go to next date\n
current_date = current_date + 3\n
\n
\n
\n
#### WEEK ####\n
if good_type[0] == \'week\':\n
current_date = DateTime(axis_start.Date()) + 1\n
#DateTime(str(axis_start.year()) + \'/\' + str(axis_start.month()) + \'/\' + str(axis_start.day() + 1))\n
# current date is any day in the week, moving to the first next Monday\n
while current_date.Day() != \'Monday\':\n
current_date = current_date + 1\n
# getting list of weeks\n
while current_date < axis_stop:\n
delimiter_list.append([int(current_date),\n
str(current_date.month()) + \'/\' + str(current_date.day()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
current_date = current_date + 7\n
\n
\n
\n
#### 1/2MONTH ####\n
if good_type[0] == \'1/2month\':\n
# getting first valid date\n
if axis_start.month() == 12 and axis_start.day() > 15:\n
# need to go to the next year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\' )\n
elif axis_start.day() > 15:\n
# need to go to next month\n
current_date = DateTime(str(axis_start.year()) + \'/\' + str((axis_start.month() +1)) + \'/1\')\n
else:\n
# need to go to next part of current month\n
current_date = DateTime(str(axis_start.year()) + \'/\' + str(axis_start.month()) + \'/15\')\n
# getting list of months\n
while current_date < axis_stop:\n
if current_date.day() == 1:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.month()) + \'/\' + str(current_date.day()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
if current_date.month() == 12 and current_date.day() == 15:\n
# need to go to the next year\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\' )\n
elif current_date.day() == 15:\n
# need to go to next month\n
current_date = DateTime(str(current_date.year()) + \'/\' + str((current_date.month() +1)) + \'/1\')\n
else:\n
# need to go to next year\n
current_date = DateTime(str(current_date.year()) + \'/\' + str((current_date.month())) + \'/15\')\n
\n
\n
#### MONTH ####\n
if good_type[0] == \'month\':\n
# getting first valid date\n
if axis_start.month() == 12:\n
# need to go to the next year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(axis_start.year()) + \'/\' + str((axis_start.month() +1)) + \'/1\')\n
# getting list of months\n
while current_date < axis_stop:\n
if current_date.month() == 1:\n
delimiter = 2\n
elif current_date.month() == 7:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.year()) + \'/\' + str(current_date.month()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
if current_date.month() == 12:\n
# need to go to the next year\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(current_date.year()) + \'/\' + str((current_date.month() +1)) + \'/1\')\n
\n
\n
\n
## 3 MONTHS ##\n
if good_type[0] == \'3months\':\n
# getting first valid date\n
if axis_start.month() > 9:\n
# need to go to the next year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\' )\n
elif axis_start.month() > 6:\n
current_date = DateTime(str(axis_start.year()) + \'/10/1\')\n
elif axis_start.month() > 3:\n
current_date = DateTime(str(axis_start.year()) + \'/7/1\')\n
else:\n
current_date = DateTime(str(axis_start.year()) + \'/4/1\')\n
while current_date < axis_stop:\n
if current_date.month() == 1:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.year()) + \'/\' + str(current_date.month()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
if current_date.month() > 9:\n
# need to go to the next year\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(\'%s/%s/1\' % (str(current_date.year()),\n
str(current_date.month() + 3))))\n
\n
\n
## 6 MONTHS ##\n
if good_type[0] == \'6months\':\n
# getting first valid date\n
if axis_start.month() > 6:\n
# need to go to the next year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(axis_start.year()) + \'/7/1\')\n
while current_date < axis_stop:\n
if current_date.month() == 1:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.year()) + \'/\' + str(current_date.month()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
if current_date.month() > 6:\n
# need to go to the next year\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\' )\n
else:\n
current_date = DateTime(str(current_date.year()) + \'/7/1\')\n
\n
\n
#### YEAR ####\n
if good_type[0] == \'year\':\n
# getting first valid year\n
current_date = DateTime(str(axis_start.year() + 1) + \'/1/1\')\n
while current_date < axis_stop:\n
if str(current_date.year())[3:] == 0:\n
delimiter = 2\n
elif str(current_date.year())[3:] == 5:\n
delimiter = 1\n
else:\n
delimiter = 0\n
delimiter_list.append([int(current_date),\n
str(current_date.year()),\n
current_date.Day() + \' \' + str(current_date),\n
delimiter\n
])\n
current_date = DateTime(str(current_date.year() + 1) + \'/1/1\')\n
\n
return delimiter_list\n
\n
\n
else:\n
\n
delimiter_list = []\n
# secondary axis type is integer / float.\n
# building corresponding axis.\n
axis_range = axis_stop - axis_start\n
step = 1.0 / 1000.0\n
good_step = step\n
while step * delimiter_min_number < axis_range:\n
good_step = step\n
step = step * 10\n
\n
\n
# now adding first value\n
delimiter_list.append([axis_start,\'\',str(axis_start),0])\n
\n
# now going to first good step\n
modul = axis_start % good_step\n
if modul == 0:\n
#axis_start is already well placed.\n
current_step = good_step + axis_start\n
else:\n
current_step = good_step + (axis_start - modul)\n
\n
# good step is the last step under axis_range.\n
if good_step >= 1:\n
good_step = int(good_step)\n
current_step = int(current_step)\n
\n
# iterating and adding each value\n
while current_step < axis_stop:\n
delimiter_list.append([current_step,str(current_step),str(current_step),0])\n
current_step += good_step\n
\n
return delimiter_list\n
"""\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_core/Planning_generateCalendarAxis</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>axis_start, axis_stop, delimiter_min_number</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>axis_start</string>
<string>axis_stop</string>
<string>delimiter_min_number</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>delimiter_list</string>
<string>float</string>
<string>axis_range</string>
<string>type_list</string>
<string>_getitem_</string>
<string>good_type</string>
<string>_getiter_</string>
<string>date_type</string>
<string>step</string>
<string>delimiter</string>
<string>step_list</string>
<string>step_id</string>
<string>_getattr_</string>
<string>str</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_generateCalendarAxis</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
Script used by PlanningBox validator to round the bound dates to the\n
closest full day.\n
"""\n
\n
if full_date.hour() > 12:\n
return DateTime(full_date.Date()) + 1\n
else:\n
return DateTime(full_date.Date())\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_core/Planning_roundBoundToDay</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>full_date</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>full_date</string>
<string>_getattr_</string>
<string>DateTime</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_roundBoundToDay</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Script used by PlanningBox to round block bounds to the\n
closest integer value.\n
"""\n
return int(value + 0.5)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_core/Planning_roundBoundToInt</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>value</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>value</string>
<string>int</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Planning_roundBoundToInt</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2006-06-30 Thomas
* Added PlanningBox 3rd part scripts, including stats and axis generation.
2006-06-28 Kevin
* Change Categories' int_index property label to 'Sort Index'.
......
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