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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
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, \
setSecurityManager
,
newSecurityManager
from
AccessControl.User
import
nobody
from
Products.CMFActivity.ActivityRuntimeEnvironment
import
getActivityRuntimeEnvironment
from
Products.CMFCore.utils
import
getToolByName
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
...
...
@@ -107,11 +106,8 @@ class Alarm(XMLObject, PeriodicityMixin):
"""
activate_kw
=
dict
(
activate_kw
)
portal_membership
=
self
.
getPortalObject
().
portal_membership
if
fixit
or
not
self
.
getEnabled
():
checkPermission
=
portal_membership
.
checkPermission
if
not
checkPermission
(
Permissions
.
ManagePortal
,
self
):
raise
Unauthorized
(
'fixing problems or activating a disabled alarm is not allowed'
)
if
(
fixit
or
not
self
.
getEnabled
())
and
not
self
.
getPortalObject
().
portal_membership
.
checkPermission
(
Permissions
.
ManagePortal
,
self
):
raise
Unauthorized
(
'fixing problems or activating a disabled alarm is not allowed'
)
# Use UnrestrictedMethod, so that the behaviour would not
# change even if this method is invoked by random users.
...
...
@@ -329,7 +325,8 @@ class Alarm(XMLObject, PeriodicityMixin):
else
:
prefix
=
'INFO'
notification_tool
=
getToolByName
(
self
,
'portal_notifications'
)
portal
=
self
.
getPortalObject
()
notification_tool
=
portal
.
portal_notifications
candidate_list
=
self
.
getDestinationValueList
()
if
not
candidate_list
:
candidate_list
=
None
...
...
@@ -352,7 +349,7 @@ class Alarm(XMLObject, PeriodicityMixin):
notification_tool
.
sendMessage
(
recipient
=
candidate_list
,
subject
=
'[%s][%s] Alarm Notification: %s'
%
(
prefix
,
self
.
getPortalObject
()
.
getTitle
(),
self
.
getTitle
()),
(
prefix
,
portal
.
getTitle
(),
self
.
getTitle
()),
message
=
"""
Alarm Title: %s (%s)
...
...
@@ -361,7 +358,7 @@ Alarm Description:
Alarm Tool Node: %s
"""
%
(
self
.
getTitle
(),
self
.
getId
(),
self
.
getDescription
(),
self
.
getPortalObject
()
.
portal_alarms
.
getAlarmNode
()),
portal
.
portal_alarms
.
getAlarmNode
()),
attachment_list
=
attachment_list
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'getLastActiveProcess'
)
...
...
@@ -400,12 +397,12 @@ Alarm Tool Node: %s
pass
else
:
activate_kw
.
setdefault
(
'tag'
,
activity_runtime_environment
.
getTag
())
portal_activities
=
getToolByName
(
self
,
'portal_activities'
)
active_process
=
portal_activities
.
newActiveProcess
(
start_date
=
DateTime
(),
causality_value
=
self
,
activate_kw
=
activate_kw
,
**
kw
)
return
active_process
return
self
.
getPortalObject
().
portal_activities
.
newActiveProcess
(
start_date
=
DateTime
(),
causality_value
=
self
,
activate_kw
=
activate_kw
,
**
kw
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setNextAlarmDate'
)
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