From cf301661c310e766545d0af81ab515b610edfd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 26 Feb 2008 17:55:14 +0000 Subject: [PATCH] 2008-02-26 Jerome * Add 2 utility scripts for persons: Person_getAge and Person_getCareerStartDate. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19531 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../portal_skins/erp5_base/Person_getAge.xml | 178 ++++++++++++++++++ .../erp5_base/Person_getCareerStartDate.xml | 168 +++++++++++++++++ bt5/erp5_base/bt/change_log | 3 + bt5/erp5_base/bt/revision | 2 +- .../bt/template_catalog_local_role_key_list | 0 .../bt/template_catalog_role_key_list | 0 6 files changed, 350 insertions(+), 1 deletion(-) create mode 100644 bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getAge.xml create mode 100644 bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getCareerStartDate.xml create mode 100644 bt5/erp5_base/bt/template_catalog_local_role_key_list create mode 100644 bt5/erp5_base/bt/template_catalog_role_key_list diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getAge.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getAge.xml new file mode 100644 index 0000000000..568fc520bf --- /dev/null +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getAge.xml @@ -0,0 +1,178 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </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[ + +"""Returns the age of the person at the current date or at the given `at_date`.\n +If `year` is true, return the integer value, otherwise returns a translated\n +string.\n +"""\n +from DateTime import DateTime\n +from Products.ERP5Type.DateUtils import getIntervalBetweenDates\n +N_ = context.Base_translateString\n +\n +birthday = context.getBirthday()\n +if birthday is None:\n + return None\n +\n +if at_date is None:\n + at_date = DateTime()\n +\n +interval_dict = getIntervalBetweenDates(from_date=birthday,\n + to_date=at_date)\n +if year:\n + return interval_dict[\'year\']\n +\n +# mapping contains year, month & day\n +return N_("${year} Years Old", mapping=interval_dict)\n + + +]]></string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_filepath</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>at_date=None, year=0</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>2</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>at_date</string> + <string>year</string> + <string>DateTime</string> + <string>Products.ERP5Type.DateUtils</string> + <string>getIntervalBetweenDates</string> + <string>_getattr_</string> + <string>context</string> + <string>N_</string> + <string>birthday</string> + <string>None</string> + <string>interval_dict</string> + <string>_getitem_</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <tuple> + <none/> + <int>0</int> + </tuple> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Person_getAge</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getCareerStartDate.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getCareerStartDate.xml new file mode 100644 index 0000000000..dec65121be --- /dev/null +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Person_getCareerStartDate.xml @@ -0,0 +1,168 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </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>all_career_step_list = context.contentValues(portal_type=\'Career\',\n + checked_permission=\'View\')\n +\n +career_step_list = []\n +# only keep "active" career steps (and related to this organisation if given)\n +for career_step in all_career_step_list :\n + if (subordination_relative_url is None or \\\n + career_step.getSubordination() == subordination_relative_url) and \\\n + career_step.getStartDate() and \\\n + career_step.getValidationState() not in (\'cancelled\', \'deleted\'):\n + career_step_list.append(career_step)\n + \n +# sort them by start date\n +career_step_list.sort( lambda x, y: cmp(x.getStartDate(), y.getStartDate()) )\n +for career_step in career_step_list :\n + # TODO: take the first date of the last active career range.\n + # for now, we only return the first one.\n + return career_step.getStartDate()\n +\n +raise ValueError, \'No Career Step Defined.\'\n +</string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_filepath</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>subordination_relative_url=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>subordination_relative_url</string> + <string>_getattr_</string> + <string>context</string> + <string>all_career_step_list</string> + <string>career_step_list</string> + <string>_getiter_</string> + <string>career_step</string> + <string>None</string> + <string>ValueError</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>Person_getCareerStartDate</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_base/bt/change_log b/bt5/erp5_base/bt/change_log index b2f1da1299..66425151ae 100644 --- a/bt5/erp5_base/bt/change_log +++ b/bt5/erp5_base/bt/change_log @@ -1,3 +1,6 @@ +2008-02-26 Jerome +* Add 2 utility scripts for persons: Person_getAge and Person_getCareerStartDate. + 2008-1-9 Yusei * Hide document tab on organisation if erp5_dms is installed. diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision index 61f9147fdc..4e66132b50 100644 --- a/bt5/erp5_base/bt/revision +++ b/bt5/erp5_base/bt/revision @@ -1 +1 @@ -275 \ No newline at end of file +282 \ No newline at end of file diff --git a/bt5/erp5_base/bt/template_catalog_local_role_key_list b/bt5/erp5_base/bt/template_catalog_local_role_key_list new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bt5/erp5_base/bt/template_catalog_role_key_list b/bt5/erp5_base/bt/template_catalog_role_key_list new file mode 100644 index 0000000000..e69de29bb2 -- 2.30.9