Commit e6f55e42 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: do not count all Support Requests

limit parameter with count is meaningless, as count return 1 result
parent 4af3fc03
...@@ -2,19 +2,20 @@ from Products.ERP5Type.Cache import CachingMethod ...@@ -2,19 +2,20 @@ from Products.ERP5Type.Cache import CachingMethod
portal = context.getPortalObject() portal = context.getPortalObject()
def isSupportRequestCreationClosed(destination_decision=None): def isSupportRequestCreationClosed(destination_decision=None):
limit = portal.portal_preferences.getPreferredSupportRequestCreationLimit(5) limit = int(portal.portal_preferences.getPreferredSupportRequestCreationLimit(5))
kw = {} kw = {
kw['limit'] = limit 'limit': limit,
kw['portal_type'] = 'Support Request' 'portal_type': 'Support Request',
kw['simulation_state'] = ["validated","submitted"] 'simulation_state': ["validated", "submitted"],
kw['default_resource_uid'] = portal.service_module.slapos_crm_monitoring.getUid() 'resource__uid': portal.service_module.slapos_crm_monitoring.getUid()
}
if destination_decision: if destination_decision:
kw['default_destination_decision_uid'] = context.restrictedTraverse( kw['destination_decision__uid'] = context.restrictedTraverse(
destination_decision).getUid() destination_decision).getUid()
support_request_amount = context.portal_catalog.countResults(**kw)[0][0] support_request_amount_list = context.portal_catalog(**kw)
return support_request_amount >= int(limit) return limit <= len(support_request_amount_list)
return CachingMethod(isSupportRequestCreationClosed, return CachingMethod(isSupportRequestCreationClosed,
......
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