Commit da4b246c authored by Papa Tamsir Kane's avatar Papa Tamsir Kane Committed by Papa Tamsir Kane

erp5_decision: Remove unneeded scripts and comments

parent 2c3b0688
"""
List persons per division.
"""
source_value = context.getSourceDecisionValue()
source_type = source_value.getPortalType()
if source_type == 'Organisation':
organisation = source_value
elif source_type == 'Person':
organisation = source_value.getCareerSubordinationValue()
else:
organisation = source_value.getSubordinationValue()
person_list = []
for person in context.portal_catalog(
portal_type='Person',
subordination_uid = organisation.getUid()):
person_list.append([person.getTitle(), person.getRelativeUrl()])
return person_list
<?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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Decision_getSourceDecisionDepartmentPersonList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
Email the person who must make a decision.
We need proxy roles so we're able to check Persons' preferences
for any context this script is executed from.
"""
def getPreferenceForUser(owner_id):
"""
Return Preference object for user
"""
preference_list = context.portal_preferences.searchFolder(
portal_type = 'Preference',
owner = owner_id)
preference_list = [x for x in preference_list if x.getProperty('preference_state', 'broken') in ('enabled', 'global')]
if len(preference_list):
return preference_list[0]
notification_message = context.NotificationTool_getDocumentValue(notification_reference)
message = notification_message.asText(substitution_method_parameter_dict={'mapping_dict':mapping_dict})
subject = notification_message.asSubjectText(substitution_method_parameter_dict={'mapping_dict':mapping_dict})
# we can have Organisation, Positions, etc for source_decision_value
# so inform them
source_decision_value = context.getSourceDecisionValue()
if source_decision_value is not None:
person_list = []
if source_decision_value.getPortalType() == 'Person':
person_list = [source_decision_value]
elif source_decision_value.getPortalType() == 'Organisation':
for person in context.Base_getPersonListForOrganisation(source_decision_value, validation_state='validated'):
person_preference = getPreferenceForUser(person.getReference())
if person_preference is not None:
# check preferences for user who is department manager if he wants to receive notifications or not?
is_preferred_send_email_notification_only_for_own_decision = person_preference.isPreferredSendEmailNotificationOnlyForOwnDecision()
#context.log('%s %s' %(person_preference.getTitle(), is_preferred_send_email_notification_only_for_own_decision))
if not is_preferred_send_email_notification_only_for_own_decision:
person_list.append(person)
else:
# no preference for user so we inform unconditionally
person_list.append(person)
elif source_decision_value.getPortalType() == 'Position':
person_list = context.Base_getPersonListForPosition(source_decision_value)
if person_list:
for reference in [x.getReference() for x in person_list]:
context.portal_notifications.sendMessage(
recipient=reference,
subject=subject,
message=message)
<?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>_params</string> </key>
<value> <string>notification_reference, mapping_dict</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Decision_notifySourceDecisionValue</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
""" """
Change source of decision. Change source of decision.
""" """
from AccessControl import getSecurityManager
request=context.REQUEST request=context.REQUEST
causality_value = context.getCausalityValue()
current_person = context.ERP5Site_getAuthenticatedMemberPersonValue()
if current_person is None:
title = getSecurityManager().getUser().getId()
else:
title = current_person.getTitle()
# Set new source # Set new source
source_decision = context.portal_catalog.getResultValue( source_decision = context.portal_catalog.getResultValue(
...@@ -20,12 +11,4 @@ context.setSourceDecisionValue(source_decision) ...@@ -20,12 +11,4 @@ context.setSourceDecisionValue(source_decision)
context.setTitle('Approval by %s' % source_decision.getTitle()) context.setTitle('Approval by %s' % source_decision.getTitle())
# Send email as activity
'''
context.activate().Decision_sendAssignNotification(
decision_id=context.getId(),
assignor_person_title=title,
assignee_person_reference=source_decision.getReference())
'''
return context.Workflow_statusModify(form_id, dialog_id, **kw) return context.Workflow_statusModify(form_id, dialog_id, **kw)
""" """
Update related "Document" to a Decision when a Decision is decided (approved or refused) Update related "Document" to a Decision when a Decision is decided (approved or refused)
Related "Document" can be of any type.
We need proxy roles as not always current approver has enough rights to change related Documents. We need proxy roles as not always current approver has enough rights to change related Documents.
""" """
portal = context.getPortalObject() portal = context.getPortalObject()
......
...@@ -9,5 +9,3 @@ for decision_line in decision.contentValues(filter = {'portal_type': 'Decision L ...@@ -9,5 +9,3 @@ for decision_line in decision.contentValues(filter = {'portal_type': 'Decision L
if decision_line.getSimulationState() != 'decided': if decision_line.getSimulationState() != 'decided':
decision_line.setApproval(approval) decision_line.setApproval(approval)
decision_line.decide() decision_line.decide()
#context.activate().Base_notifyDecisionStateChange(decision.getCausalityUid(), decision.getUid())
...@@ -8,14 +8,3 @@ decision = state_change['object'] ...@@ -8,14 +8,3 @@ decision = state_change['object']
for decision_line in decision.contentValues(filter = {'portal_type': 'Decision Line'}): for decision_line in decision.contentValues(filter = {'portal_type': 'Decision Line'}):
decision_line.post() decision_line.post()
'''
causality_value = decision.getCausalityValue()
document_url = causality_value.absolute_url()
mapping_dict = {"url" : decision.absolute_url(),
"document_url": document_url,
"initiator_title": causality_value.Base_getOwnerValue().getTitle()}
decision.activate().Decision_notifySourceDecisionValue('decision-posted', mapping_dict)
'''
<?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>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Decision_checkConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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