Commit 17669c01 authored by Jérome Perrin's avatar Jérome Perrin

crm: fix pylint messages and enable coding style

parent 6db1da77
...@@ -4,14 +4,14 @@ connected. This script will use efficiently caches in order to slow ...@@ -4,14 +4,14 @@ connected. This script will use efficiently caches in order to slow
down as less a possible the user interface down as less a possible the user interface
""" """
from DateTime import DateTime from DateTime import DateTime
portal = context.getPortalObject()
user_name = context.portal_membership.getAuthenticatedMember().getId() user_name = portal.portal_membership.getAuthenticatedMember().getId()
def getUnreadAcknowledgementListForUser(user_name=None): def getUnreadAcknowledgementListForUser(user_name=None):
# We give the portal type "Mass Notification" for now, we can # We give the portal type "Mass Notification" for now, we can
# have a getPortalAcknowledgeableTypeList method in the future # have a getPortalAcknowledgeableTypeList method in the future
portal_acknowledgements = getattr(context.getPortalObject(), portal_acknowledgements = getattr(portal, "portal_acknowledgements", None)
"portal_acknowledgements", None)
result = [] result = []
if portal_acknowledgements is not None: if portal_acknowledgements is not None:
result = context.portal_acknowledgements.getUnreadDocumentUrlList( result = context.portal_acknowledgements.getUnreadDocumentUrlList(
...@@ -23,13 +23,12 @@ from Products.ERP5Type.Cache import CachingMethod ...@@ -23,13 +23,12 @@ from Products.ERP5Type.Cache import CachingMethod
# Cache for every user the list of url of not acknowledge documents # Cache for every user the list of url of not acknowledge documents
getUnreadAcknowledgementList = CachingMethod(getUnreadAcknowledgementListForUser, getUnreadAcknowledgementList = CachingMethod(getUnreadAcknowledgementListForUser,
"getUnreadAcknowledgementListForUser") "getUnreadAcknowledgementListForUser")
portal = context.getPortalObject()
return_list = [] return_list = []
url_list = getUnreadAcknowledgementList(user_name=user_name) url_list = getUnreadAcknowledgementList(user_name=user_name)
# For every not acknowledge document, check that documents are still not # For every not acknowledge document, check that documents are still not
# acknowledged and return them for the user interface # acknowledged and return them for the user interface
if len(url_list) > 0: if len(url_list) > 0:
acknowledgement_list = context.portal_acknowledgements.getUnreadAcknowledgementList( acknowledgement_list = portal.portal_acknowledgements.getUnreadAcknowledgementList(
url_list=url_list, user_name=user_name) url_list=url_list, user_name=user_name)
for acknowledgement in acknowledgement_list: for acknowledgement in acknowledgement_list:
#bulletin = acknowledgement.getCausalityValue() #bulletin = acknowledgement.getCausalityValue()
......
...@@ -3,7 +3,7 @@ getResultValue = context.portal_catalog.getResultValue ...@@ -3,7 +3,7 @@ getResultValue = context.portal_catalog.getResultValue
from Products.ERP5Type.Utils import Email_parseAddressHeader from Products.ERP5Type.Utils import Email_parseAddressHeader
result = [] result = []
for name, recipient in Email_parseAddressHeader(text): for _, recipient in Email_parseAddressHeader(text):
if recipient: if recipient:
email = getResultValue(url_string={'query':recipient, 'key':'ExactMatch'}, portal_type='Email', parent_portal_type='Person') email = getResultValue(url_string={'query':recipient, 'key':'ExactMatch'}, portal_type='Email', parent_portal_type='Person')
if email is None: if email is None:
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
This script returns all possible projects or tickets This script returns all possible projects or tickets
which can be used a follow up to a CRM event. which can be used a follow up to a CRM event.
""" """
type_list = context.getPortalTicketTypeList() + context.getPortalProjectTypeList() portal = context.getPortalObject()
node_list = context.portal_catalog(portal_type=type_list, simulation_state=['draft', 'open', 'validated', 'contacted']) type_list = portal.getPortalTicketTypeList() + portal.getPortalProjectTypeList()
return map(lambda x:(x.getTitle(), x.getRelativeUrl()), node_list) node_list = portal.portal_catalog(portal_type=type_list, simulation_state=['draft', 'open', 'validated', 'contacted'])
return [(x.getTitle(), x.getRelativeUrl) for x in node_list]
...@@ -15,7 +15,7 @@ notification_message = portal.notification_message_module.NotificationTool_getDo ...@@ -15,7 +15,7 @@ notification_message = portal.notification_message_module.NotificationTool_getDo
language=language) language=language)
assert notification_message is not None, "%s not found." % resource_reference assert notification_message is not None, "%s not found." % resource_reference
event = context.Base_addEvent(title='', context.Base_addEvent(title='',
direction='outgoing', direction='outgoing',
portal_type=event_portal_type, portal_type=event_portal_type,
resource=notification_message.getSpecialise(), resource=notification_message.getSpecialise(),
......
from Products.ERP5Form.Report import ReportSection from Products.ERP5Form.Report import ReportSection
result=[] result = []
request = context.REQUEST
params = {}
selection_columns = [('simulation_state', 'State')] selection_columns = [('simulation_state', 'State')]
#Add dynamicaly ticket type columns to the form #Add dynamicaly ticket type columns to the form
#The name of column must be without spaces #The name of column must be without spaces
......
...@@ -31,14 +31,14 @@ unassigned_dic['ticket_type']=portal.Base_translateString("Unassigned") ...@@ -31,14 +31,14 @@ unassigned_dic['ticket_type']=portal.Base_translateString("Unassigned")
#column_list.append(new_dic) #column_list.append(new_dic)
#Return index of uid into the list and append if not exists #Return index of uid into the list and append if not exists
def createReturnLine(uid,list): def createReturnLine(uid, list_):
for i in xrange(len(list)): for i in xrange(len(list_)):
if list[i]['uid']==uid: if list[i]['uid']==uid:
return i return i
new_dic=default_dic.copy() new_dic=default_dic.copy()
new_dic['uid']=uid new_dic['uid']=uid
list.append(new_dic) list_.append(new_dic)
return len(list)-1 return len(list_)-1
# Prepare the parameters to filter # Prepare the parameters to filter
query_dict = {} query_dict = {}
......
from Products.ERP5Form.Report import ReportSection from Products.ERP5Form.Report import ReportSection
result=[] result = []
request = context.REQUEST
selection_columns = [('ticket_title', 'Title')] selection_columns = [('ticket_title', 'Title')]
selection_columns.append(('ticket_type', 'Module')) selection_columns.append(('ticket_type', 'Module'))
selection_columns.append(('resource','Type')) selection_columns.append(('resource','Type'))
......
from Products.PythonScripts.standard import Object
request = container.REQUEST request = container.REQUEST
RESPONSE = request.RESPONSE
stat_line = request.get('stat_line', None) stat_line = request.get('stat_line', None)
return stat_line return stat_line
from Products.PythonScripts.standard import Object
request = container.REQUEST request = container.REQUEST
RESPONSE = request.RESPONSE
stat_line = request.get('stat_line', None) stat_line = request.get('stat_line', None)
return stat_line return stat_line
...@@ -8,7 +8,7 @@ if dms_module is not None: ...@@ -8,7 +8,7 @@ if dms_module is not None:
# index is numeric and comes with uid # index is numeric and comes with uid
attachment_index = int(uid.split('index_')[-1]) attachment_index = int(uid.split('index_')[-1])
attachment_info = [i for i in attachment_info_list if i['index'] == attachment_index][0] attachment_info = [i for i in attachment_info_list if i['index'] == attachment_index][0]
file = context.getAttachmentData(index=attachment_index) file_ = context.getAttachmentData(index=attachment_index)
document = dms_module.newContent(follow_up=context.getFollowUp(), document = dms_module.newContent(follow_up=context.getFollowUp(),
portal_type = line['content_type'], portal_type = line['content_type'],
description = line['description'], description = line['description'],
...@@ -17,7 +17,7 @@ if dms_module is not None: ...@@ -17,7 +17,7 @@ if dms_module is not None:
language = line['language'], language = line['language'],
reference= line['reference'], reference= line['reference'],
title = line['title']) title = line['title'])
document.edit(source_reference=attachment_info['file_name'], file=file) document.edit(source_reference=attachment_info['file_name'], file=file_)
if len(uids) == 1: if len(uids) == 1:
message = Base_translateString('${portal_type} created successfully.', message = Base_translateString('${portal_type} created successfully.',
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>uids=[], listbox=None, **kw</string> </value> <value> <string>uids=(), listbox=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -2,15 +2,14 @@ ...@@ -2,15 +2,14 @@
# the current event # the current event
from DateTime import DateTime from DateTime import DateTime
from Products.CMFCore.WorkflowCore import WorkflowException from Products.CMFCore.WorkflowCore import WorkflowException
N_ = context.Base_translateString
date = DateTime() date = DateTime()
portal = context.getPortalObject() portal = context.getPortalObject()
if portal_type not in portal.event_module.getVisibleAllowedContentTypeList(): if portal_type not in portal.event_module.getVisibleAllowedContentTypeList():
raise WorkflowException, "You Don't Have Permission to Add New Event" raise WorkflowException("You Don't Have Permission to Add New Event")
# Create the draft Event # Create the draft Event
related_event = portal.event_module.newContent( portal.event_module.newContent(
portal_type=portal_type, portal_type=portal_type,
title=title, title=title,
description=description, description=description,
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
""" """
# this script allows to create a new follow up ticket for a given event # this script allows to create a new follow up ticket for a given event
event_object = context
event_module = context.getPortalObject().getDefaultModule(respond_event_portal_type) event_module = context.getPortalObject().getDefaultModule(respond_event_portal_type)
# Create the outgoing # Create the outgoing
respond_event = event_module.newContent( respond_event = event_module.newContent(
......
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
contribution_registry = context.portal_contribution_registry
base_list = [] base_list = []
for attachment in context.getAttachmentInformationList(): for attachment in context.getAttachmentInformationList():
...@@ -8,7 +7,7 @@ for attachment in context.getAttachmentInformationList(): ...@@ -8,7 +7,7 @@ for attachment in context.getAttachmentInformationList():
if attachment['uid'] not in ['part_1', 'part_0']: if attachment['uid'] not in ['part_1', 'part_0']:
filename = context.getTitle() filename = context.getTitle()
if attachment.has_key("file_name"): if attachment.has_key("file_name"):
filename=attachment["file_name"] filename=attachment["file_name"]
pt = "File" pt = "File"
temp_base_id = 'index_'.join([attachment["uid"], str(attachment["index"])]) temp_base_id = 'index_'.join([attachment["uid"], str(attachment["index"])])
base_list.append(newTempBase(context, id=temp_base_id, base_list.append(newTempBase(context, id=temp_base_id,
......
...@@ -45,7 +45,7 @@ subject = content_information.get('Subject', '') ...@@ -45,7 +45,7 @@ subject = content_information.get('Subject', '')
body = context.asText() body = context.asText()
portal_type = None portal_type = None
for text in (subject, body): for text in (subject, body):
portal_type, matched_value = context.Base_findPortalTypeNameAndMatchedValueForEvent(text) portal_type, _ = context.Base_findPortalTypeNameAndMatchedValueForEvent(text)
if portal_type is not None: if portal_type is not None:
break break
......
...@@ -20,7 +20,7 @@ if notification_message is not None: ...@@ -20,7 +20,7 @@ if notification_message is not None:
target_format = "txt" target_format = "txt"
if context.getContentType() == 'text/html': if context.getContentType() == 'text/html':
target_format = "html" target_format = "html"
mime, text_content = notification_message.convert(target_format, _, text_content = notification_message.convert(target_format,
substitution_method_parameter_dict=substitution_method_parameter_dict) substitution_method_parameter_dict=substitution_method_parameter_dict)
context.setTextContent(text_content) context.setTextContent(text_content)
context.setAggregateSet( context.setAggregateSet(
......
portal = context.getPortalObject() portal = context.getPortalObject()
hmac = portal.Base_getHMACHexdigest(key=portal.Base_getEventHMACKey(), message=event_value.getId())
def getSubstitutionMappingDict(): def getSubstitutionMappingDict():
destination = event_value.getDestinationValue() destination = event_value.getDestinationValue()
......
...@@ -75,7 +75,7 @@ def getResourceItemList(): ...@@ -75,7 +75,7 @@ def getResourceItemList():
getCategoryTitle = getCategoryTitle_ getCategoryTitle = getCategoryTitle_
else: else:
getCategoryTitle = lambda category, depth: None getCategoryTitle = lambda category, depth: None
def getResourceTitle(resource, category, depth): def getResourceTitle(resource, category, depth): # pylint:disable=function-redefined
resource_title = getattr(resource, accessor_id)() resource_title = getattr(resource, accessor_id)()
# depth - 1 because we are at category's child level # depth - 1 because we are at category's child level
category_path = getCategoryTitle_(category, depth - 1) category_path = getCategoryTitle_(category, depth - 1)
......
"""
"""
# XXX: Tickets are not documents, so content_type on them has no sense at all # XXX: Tickets are not documents, so content_type on them has no sense at all
# Set preferred text format # Set preferred text format
#context.edit(content_type = context.portal_preferences.getPreferredTextFormat()) #context.edit(content_type = context.portal_preferences.getPreferredTextFormat())
...@@ -56,7 +56,7 @@ class TestCRMNotificationTool(TestNotificationTool): ...@@ -56,7 +56,7 @@ class TestCRMNotificationTool(TestNotificationTool):
message='Message') message='Message')
self.tic() self.tic()
last_message, = self.portal.MailHost._message_list last_message, = self.portal.MailHost._message_list
mfrom, mto, messageText = last_message mfrom, mto, _ = last_message
self.assertEqual('Portal Administrator <site@example.invalid>', mfrom) self.assertEqual('Portal Administrator <site@example.invalid>', mfrom)
self.assertEqual(['userA@example.invalid'], mto) self.assertEqual(['userA@example.invalid'], mto)
......
object = state_change['object'] state_change['object'].Base_checkConsistency()
object.Base_checkConsistency()
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