Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Léo-Paul Géneau
slapos.core
Commits
c41798ce
Commit
c41798ce
authored
May 13, 2019
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: Use cachingMethod to not over query the catalog too much.
parent
bd5bfca7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/ERP5Site_isSupportRequestCreationClosed.py
...crm_monitoring/ERP5Site_isSupportRequestCreationClosed.py
+16
-11
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
+3
-0
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/ERP5Site_isSupportRequestCreationClosed.py
View file @
c41798ce
# HARDCODED LIMIT TO BE MOVED TO GLOBAL PREFERENCES
from
Products.ERP5Type.Cache
import
CachingMethod
portal
=
context
.
getPortalObject
()
limit
=
portal
.
portal_preferences
.
getPreferredSupportRequestCreationLimit
(
5
)
def
isSupportRequestCreationClosed
(
destination_decision
=
None
):
limit
=
portal
.
portal_preferences
.
getPreferredSupportRequestCreationLimit
(
5
)
kw
[
'limit'
]
=
limit
kw
[
'portal_type'
]
=
'Support Request'
kw
[
'simulation_state'
]
=
[
"validated"
,
"submitted"
]
kw
[
'default_resource_uid'
]
=
portal
.
service_module
.
slapos_crm_monitoring
.
getUid
()
if
destination_decision
:
kw
[
'default_destination_decision_uid'
]
=
context
.
restrictedTraverse
(
destination_decision
).
getUid
()
kw
=
{}
kw
[
'limit'
]
=
limit
kw
[
'portal_type'
]
=
'Support Request'
kw
[
'simulation_state'
]
=
[
"validated"
,
"submitted"
]
kw
[
'default_resource_uid'
]
=
portal
.
service_module
.
slapos_crm_monitoring
.
getUid
()
if
destination_decision
:
kw
[
'default_destination_decision_uid'
]
=
context
.
restrictedTraverse
(
destination_decision
).
getUid
()
support_request_list
=
context
.
portal_catalog
(
**
kw
)
support_request_amount
=
context
.
portal_catalog
.
countResults
(
**
kw
)[
0
][
0
]
return
support_request_amount
>=
limit
return
len
(
support_request_list
)
>=
limit
return
CachingMethod
(
isSupportRequestCreationClosed
,
"isSupportRequestCreationClosed"
)(
destination_decision
=
destination_decision
)
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
View file @
c41798ce
...
...
@@ -2221,6 +2221,9 @@ class TestSlapOSisSupportRequestCreationClosed(TestCRMSkinsMixin):
newSupportRequest
()
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
newSupportRequest
()
# It hit cache
self
.
assertFalse
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
self
.
clearCache
()
self
.
assertTrue
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
(
url
))
self
.
assertTrue
(
self
.
portal
.
ERP5Site_isSupportRequestCreationClosed
())
...
...
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