Commit 1558d49b authored by Romain Courteaud's avatar Romain Courteaud

Simplify Computer security calculation.

Do not depends on external documents to fetch informations.
parent c169e70d
<type_roles>
<role id='Auditor'>
<property id='title'>Allocation scope</property>
<property id='condition'>python: here.getAllocationScope('').startswith('open')</property>
<property id='base_category_script'>ComputerType_getSecurityCategoryFromAllocationScope</property>
<multi_property id='base_category'>aggregate</multi_property>
</role>
<role id='Assignee'>
<property id='title'>Computer Agent</property>
<property id='description'>Monovalued role</property>
......@@ -10,12 +16,6 @@
<multi_property id='category'>group/company</multi_property>
<multi_property id='base_category'>group</multi_property>
</role>
<role id='Auditor'>
<property id='title'>Sale Trade Condition allocation</property>
<property id='condition'>python: here.getAllocationScope('').startswith('open')</property>
<property id='base_category_script'>ComputerType_getSecurityCategoryFromSaleTradeCondition</property>
<multi_property id='base_category'>aggregate</multi_property>
</role>
<role id='Assignor'>
<property id='title'>Self Computer</property>
<property id='condition'>python: context.getReference("") != ""</property>
......
......@@ -64,38 +64,23 @@ if obj is None:\n
return []\n
\n
portal = obj.getPortalObject()\n
\n
sale_supply_line_list = portal.portal_catalog(\n
aggregate_relative_url=obj.getRelativeUrl(),\n
portal_type="Sale Supply Line",\n
validation_state="validated")\n
computer = obj\n
\n
category_list = []\n
public = 0\n
\n
for sale_supply_line in sale_supply_line_list:\n
sale_supply_line = sale_supply_line.getObject()\n
sale_trade_condition = sale_supply_line.getParentValue()\n
if sale_trade_condition.getPortalType() == \'Sale Trade Condition\':\n
\n
person_list = sale_supply_line.getDestinationSectionValueList(portal_type="Person")\n
if person_list:\n
for person in person_list:\n
category_list.extend([x.getReference() for x in person.portal_catalog(\n
portal_type="Open Sale Order",\n
validation_state="validated",\n
destination_decision_relative_url=person.getRelativeUrl())])\n
else:\n
# Global\n
public = 1\n
break\n
scope = computer.getAllocationScope()\n
if scope == \'open/public\':\n
return {"Auditor": ["R-SHADOW-PERSON"]}\n
elif scope == \'open/private\':\n
person = computer.getSourceAdministrationValue(portal_type="Person")\n
if person is not None:\n
return {"Auditor": ["SHADOW-%s" % person.getReference()]}\n
elif scope == \'open/friend\':\n
person_list = computer.getDestinationSectionValueList(portal_type="Person")\n
if person_list:\n
return {"Auditor": ["SHADOW-%s" % x.getReference() for x in person_list]}\n
\n
if public:\n
return {"Auditor": ["R-SHADOW"]}\n
elif category_list:\n
return {"Auditor": ["SHADOW-%s" % x for x in category_list]}\n
else:\n
return []\n
return category_list\n
</string> </value>
</item>
<item>
......@@ -112,7 +97,7 @@ else:\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputerType_getSecurityCategoryFromSaleTradeCondition</string> </value>
<value> <string>ComputerType_getSecurityCategoryFromAllocationScope</string> </value>
</item>
</dictionary>
</pickle>
......
13
\ No newline at end of file
14
\ No newline at end of file
515
\ No newline at end of file
516
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>computer = context\n
return computer.portal_catalog.getResultValue(\n
portal_type="Sale Supply Line",\n
aggregate_relative_url=computer.getRelativeUrl(),\n
validation_state="validated")\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_getRelatedSaleSupplyLine</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -62,31 +62,28 @@ elif allocation_scope.startswith(\'open\'):\n
else:\n
capacity_scope = \'close\'\n
\n
computer.edit(\n
allocation_scope=allocation_scope,\n
capacity_scope=capacity_scope,\n
)\n
edit_kw = {\n
\'allocation_scope\': allocation_scope,\n
\'capacity_scope\': capacity_scope,\n
}\n
\n
sale_supply_line = computer.Computer_getRelatedSaleSupplyLine()\n
sale_trade_condition = sale_supply_line.getParentValue()\n
self_person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
self_email = self_person.getDefaultEmailCoordinateText()\n
if allocation_scope == \'open/public\':\n
# reset friends and update in place\n
sale_trade_condition.edit(\n
subject_list=[\'\'],\n
destination_section=None)\n
edit_kw[\'subject_list\'] = [\'\']\n
edit_kw[\'destination_section\'] = None\n
elif allocation_scope == \'open/personal\':\n
# reset friends to self and update in place\n
sale_trade_condition.edit(\n
subject_list=[self_email],\n
destination_section_value=self_person)\n
edit_kw[\'subject_list\'] = [self_email]\n
edit_kw[\'destination_section_value\'] = self_person\n
else:\n
if self_email not in subject_list:\n
# add self as friend\n
subject_list.append(self_email)\n
sale_trade_condition.edit(\n
subject_list=subject_list)\n
edit_kw[\'subject_list\'] = subject_list\n
\n
computer.edit(**edit_kw)\n
\n
message = context.Base_translateString("Allocation scope updated!")\n
return computer.Base_redirect(keep_items={\'portal_status_message\': message})\n
......
......@@ -305,7 +305,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.Computer_getRelatedSaleSupplyLine().getSubjectList()</string> </value>
<value> <string>python: here.getSubjectList()</string> </value>
</item>
</dictionary>
</pickle>
......
476
\ No newline at end of file
477
\ No newline at end of file
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