Commit 9d5e1370 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: block services if user must pay his invoices

parent 39bbf5c7
item = context item = context
portal = context.getPortalObject() portal = context.getPortalObject()
if (item.getPortalType() == 'Instance Tree') and (item.getSlapState() == "destroy_requested"): if item.getValidationState() in ['invalidated', 'archived']:
return 'todestroy' return 'todestroy'
# If no open order, subscription must be approved # If no open order, subscription must be approved
...@@ -15,7 +15,33 @@ open_sale_order_movement_list = portal.portal_catalog( ...@@ -15,7 +15,33 @@ open_sale_order_movement_list = portal.portal_catalog(
if len(open_sale_order_movement_list) == 0: if len(open_sale_order_movement_list) == 0:
return "not_subscribed" return "not_subscribed"
# Check if there are some ongoing Regularisation Requestion # Check if there are some ongoing Regularisation Request
# if so, return to_pay # if so, return to_pay
entity_uid = None
item_portal_type = item.getPortalType()
if item_portal_type == 'Instance Tree':
entity_uid = item.getDestinationSectionUid()
elif item_portal_type == 'Project':
entity_uid = item.getDestinationUid()
elif item_portal_type == 'Compute Node':
project = item.getFollowUpValue()
if project is not None:
entity_uid = project.getDestinationUid()
else:
raise NotImplementedError('Unsupported item %s' % item.getRelativeUrl())
regularisation_request_list = portal.portal_catalog(
portal_type='Regularisation Request',
destination__uid=entity_uid or -1,
simulation_state='suspended',
resource__uid=[
portal.service_module.slapos_crm_stop_acknowledgement.getUid(),
portal.service_module.slapos_crm_delete_reminder.getUid(),
portal.service_module.slapos_crm_delete_acknowledgement.getUid(),
],
limit=1
)
if len(regularisation_request_list) == 1:
return "to_pay"
return "subscribed" return "subscribed"
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