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

crm: fix pylint messages and enable coding style

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