Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ekaterina
erp5
Commits
9332b823
Commit
9332b823
authored
Jan 26, 2018
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alarm: Assorted coding style improvements.
Especially, stop using getToolByName.
parent
ecffced1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
product/ERP5/Document/Alarm.py
product/ERP5/Document/Alarm.py
+12
-15
No files found.
product/ERP5/Document/Alarm.py
View file @
9332b823
...
@@ -35,7 +35,6 @@ from AccessControl.SecurityManagement import getSecurityManager, \
...
@@ -35,7 +35,6 @@ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager
,
newSecurityManager
setSecurityManager
,
newSecurityManager
from
AccessControl.User
import
nobody
from
AccessControl.User
import
nobody
from
Products.CMFActivity.ActivityRuntimeEnvironment
import
getActivityRuntimeEnvironment
from
Products.CMFActivity.ActivityRuntimeEnvironment
import
getActivityRuntimeEnvironment
from
Products.CMFCore.utils
import
getToolByName
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
...
@@ -107,11 +106,8 @@ class Alarm(XMLObject, PeriodicityMixin):
...
@@ -107,11 +106,8 @@ class Alarm(XMLObject, PeriodicityMixin):
"""
"""
activate_kw
=
dict
(
activate_kw
)
activate_kw
=
dict
(
activate_kw
)
portal_membership
=
self
.
getPortalObject
().
portal_membership
if
(
fixit
or
not
self
.
getEnabled
())
and
not
self
.
getPortalObject
().
portal_membership
.
checkPermission
(
Permissions
.
ManagePortal
,
self
):
if
fixit
or
not
self
.
getEnabled
():
raise
Unauthorized
(
'fixing problems or activating a disabled alarm is not allowed'
)
checkPermission
=
portal_membership
.
checkPermission
if
not
checkPermission
(
Permissions
.
ManagePortal
,
self
):
raise
Unauthorized
(
'fixing problems or activating a disabled alarm is not allowed'
)
# Use UnrestrictedMethod, so that the behaviour would not
# Use UnrestrictedMethod, so that the behaviour would not
# change even if this method is invoked by random users.
# change even if this method is invoked by random users.
...
@@ -329,7 +325,8 @@ class Alarm(XMLObject, PeriodicityMixin):
...
@@ -329,7 +325,8 @@ class Alarm(XMLObject, PeriodicityMixin):
else
:
else
:
prefix
=
'INFO'
prefix
=
'INFO'
notification_tool
=
getToolByName
(
self
,
'portal_notifications'
)
portal
=
self
.
getPortalObject
()
notification_tool
=
portal
.
portal_notifications
candidate_list
=
self
.
getDestinationValueList
()
candidate_list
=
self
.
getDestinationValueList
()
if
not
candidate_list
:
if
not
candidate_list
:
candidate_list
=
None
candidate_list
=
None
...
@@ -352,7 +349,7 @@ class Alarm(XMLObject, PeriodicityMixin):
...
@@ -352,7 +349,7 @@ class Alarm(XMLObject, PeriodicityMixin):
notification_tool
.
sendMessage
(
recipient
=
candidate_list
,
notification_tool
.
sendMessage
(
recipient
=
candidate_list
,
subject
=
'[%s][%s] Alarm Notification: %s'
%
subject
=
'[%s][%s] Alarm Notification: %s'
%
(
prefix
,
self
.
getPortalObject
()
.
getTitle
(),
self
.
getTitle
()),
(
prefix
,
portal
.
getTitle
(),
self
.
getTitle
()),
message
=
"""
message
=
"""
Alarm Title: %s (%s)
Alarm Title: %s (%s)
...
@@ -361,7 +358,7 @@ Alarm Description:
...
@@ -361,7 +358,7 @@ Alarm Description:
Alarm Tool Node: %s
Alarm Tool Node: %s
"""
%
(
self
.
getTitle
(),
self
.
getId
(),
self
.
getDescription
(),
"""
%
(
self
.
getTitle
(),
self
.
getId
(),
self
.
getDescription
(),
self
.
getPortalObject
()
.
portal_alarms
.
getAlarmNode
()),
portal
.
portal_alarms
.
getAlarmNode
()),
attachment_list
=
attachment_list
)
attachment_list
=
attachment_list
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'getLastActiveProcess'
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'getLastActiveProcess'
)
...
@@ -400,12 +397,12 @@ Alarm Tool Node: %s
...
@@ -400,12 +397,12 @@ Alarm Tool Node: %s
pass
pass
else
:
else
:
activate_kw
.
setdefault
(
'tag'
,
activity_runtime_environment
.
getTag
())
activate_kw
.
setdefault
(
'tag'
,
activity_runtime_environment
.
getTag
())
portal_activities
=
getToolByName
(
self
,
'portal_activities'
)
return
self
.
getPortalObject
().
portal_activities
.
newActiveProcess
(
active_process
=
portal_activities
.
newActiveProcess
(
start_date
=
DateTime
(),
start_date
=
DateTime
(),
causality_value
=
self
,
causality_value
=
self
,
activate_kw
=
activate_kw
,
activate_kw
=
activate_kw
,
**
kw
)
**
kw
return
active_process
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setNextAlarmDate'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setNextAlarmDate'
)
def
setNextAlarmDate
(
self
,
current_date
=
None
):
def
setNextAlarmDate
(
self
,
current_date
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment