Commit 786eb339 authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_crm: migrate to new bt format

parent e452daa2
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Regularisation Request",
simulation_state=["suspended"],
method_id='RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,18 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
method_id=\'RegularisationRequest_cancelInvoiceIfPersonOpenOrderIsEmpty\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
# XXX TODO: use getInventory to directly fetch user with a wrong balance
portal.portal_catalog.searchAndActivate(
portal_type="Person",
validation_state="validated",
reference=NegatedQuery(SimpleQuery(reference=None)),
default_email_text=NegatedQuery(SimpleQuery(default_email_text=None)),
method_id='Person_checkToCreateRegularisationRequest',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,23 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery\n
\n
# XXX TODO: use getInventory to directly fetch user with a wrong balance\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Person", \n
validation_state="validated",\n
reference=NegatedQuery(SimpleQuery(reference=None)),\n
default_email_text=NegatedQuery(SimpleQuery(default_email_text=None)),\n
method_id=\'Person_checkToCreateRegularisationRequest\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
sub_tag = "RegularisationRequest_deleteHostingSubscriptionList"
portal.portal_catalog.searchAndActivate(
portal_type="Regularisation Request",
simulation_state=["suspended"],
default_resource_uid=portal.service_module.slapos_crm_delete_acknowledgement.getUid(),
method_id='RegularisationRequest_deleteHostingSubscriptionList',
method_args=(sub_tag,),
# Limit activity number, as method_id also calls searchAndActivate
activity_count=1,
packet_size=1,
activate_kw={'tag': tag, 'after_tag': sub_tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,24 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
sub_tag = "RegularisationRequest_deleteHostingSubscriptionList"\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
default_resource_uid=portal.service_module.slapos_crm_delete_acknowledgement.getUid(),\n
method_id=\'RegularisationRequest_deleteHostingSubscriptionList\',\n
method_args=(sub_tag,),\n
# Limit activity number, as method_id also calls searchAndActivate\n
activity_count=1,\n
packet_size=1,\n
activate_kw={\'tag\': tag, \'after_tag\': sub_tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Regularisation Request",
simulation_state=["suspended"],
method_id='RegularisationRequest_invalidateIfPersonBalanceIsOk',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,18 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
method_id=\'RegularisationRequest_invalidateIfPersonBalanceIsOk\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
sub_tag = "RegularisationRequest_stopHostingSubscriptionList"
portal.portal_catalog.searchAndActivate(
portal_type="Regularisation Request",
simulation_state=["suspended"],
default_resource_uid=[
portal.service_module.slapos_crm_stop_acknowledgement.getUid(),
portal.service_module.slapos_crm_delete_reminder.getUid(),
],
method_id='RegularisationRequest_stopHostingSubscriptionList',
method_args=(sub_tag,),
# Limit activity number, as method_id also calls searchAndActivate
activity_count=1,
packet_size=1,
activate_kw={'tag': tag, 'after_tag': sub_tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,27 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
sub_tag = "RegularisationRequest_stopHostingSubscriptionList"\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
default_resource_uid=[\n
portal.service_module.slapos_crm_stop_acknowledgement.getUid(),\n
portal.service_module.slapos_crm_delete_reminder.getUid(),\n
],\n
method_id=\'RegularisationRequest_stopHostingSubscriptionList\',\n
method_args=(sub_tag,),\n
# Limit activity number, as method_id also calls searchAndActivate\n
activity_count=1,\n
packet_size=1,\n
activate_kw={\'tag\': tag, \'after_tag\': sub_tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Regularisation Request",
simulation_state=["suspended"],
default_resource_uid=portal.service_module.slapos_crm_acknowledgement.getUid(),
method_id='RegularisationRequest_triggerAcknowledgmentEscalation',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,19 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
default_resource_uid=portal.service_module.slapos_crm_acknowledgement.getUid(),\n
method_id=\'RegularisationRequest_triggerAcknowledgmentEscalation\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Regularisation Request",
simulation_state=["suspended"],
default_resource_uid=portal.service_module.slapos_crm_delete_reminder.getUid(),
method_id='RegularisationRequest_triggerDeleteReminderEscalation',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,19 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
default_resource_uid=portal.service_module.slapos_crm_delete_reminder.getUid(),\n
method_id=\'RegularisationRequest_triggerDeleteReminderEscalation\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Regularisation Request",
simulation_state=["suspended"],
default_resource_uid=portal.service_module.slapos_crm_stop_acknowledgement.getUid(),
method_id='RegularisationRequest_triggerStopAcknowledgmentEscalation',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,19 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
default_resource_uid=portal.service_module.slapos_crm_stop_acknowledgement.getUid(),\n
method_id=\'RegularisationRequest_triggerStopAcknowledgmentEscalation\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Regularisation Request",
simulation_state=["suspended"],
default_resource_uid=portal.service_module.slapos_crm_stop_reminder.getUid(),
method_id='RegularisationRequest_triggerStopReminderEscalation',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,19 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
default_resource_uid=portal.service_module.slapos_crm_stop_reminder.getUid(),\n
method_id=\'RegularisationRequest_triggerStopReminderEscalation\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
hosting_subscription = context
assert hosting_subscription.getDefaultDestinationSection() == person_relative_url
person = hosting_subscription.getDefaultDestinationSectionValue()
slap_state = hosting_subscription.getSlapState()
if (slap_state in ['start_requested', 'stop_requested']):
person.requestSoftwareInstance(
state='destroyed',
software_release=hosting_subscription.getUrlString(),
software_title=hosting_subscription.getTitle(),
software_type=hosting_subscription.getSourceReference(),
instance_xml=hosting_subscription.getTextContent(),
sla_xml=hosting_subscription.getSlaXml(),
shared=hosting_subscription.isRootSlave()
)
return True
return False
......@@ -48,31 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
hosting_subscription = context\n
assert hosting_subscription.getDefaultDestinationSection() == person_relative_url\n
person = hosting_subscription.getDefaultDestinationSectionValue()\n
\n
slap_state = hosting_subscription.getSlapState()\n
if (slap_state in [\'start_requested\', \'stop_requested\']):\n
person.requestSoftwareInstance(\n
state=\'destroyed\',\n
software_release=hosting_subscription.getUrlString(),\n
software_title=hosting_subscription.getTitle(),\n
software_type=hosting_subscription.getSourceReference(),\n
instance_xml=hosting_subscription.getTextContent(),\n
sla_xml=hosting_subscription.getSlaXml(),\n
shared=hosting_subscription.isRootSlave()\n
)\n
return True\n
return False\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>person_relative_url, REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
hosting_subscription = context
assert hosting_subscription.getDefaultDestinationSection() == person_relative_url
person = hosting_subscription.getDefaultDestinationSectionValue()
slap_state = hosting_subscription.getSlapState()
if (slap_state == 'start_requested'):
person.requestSoftwareInstance(
state='stopped',
software_release=hosting_subscription.getUrlString(),
software_title=hosting_subscription.getTitle(),
software_type=hosting_subscription.getSourceReference(),
instance_xml=hosting_subscription.getTextContent(),
sla_xml=hosting_subscription.getSlaXml(),
shared=hosting_subscription.isRootSlave()
)
return True
return False
......@@ -48,31 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
hosting_subscription = context\n
assert hosting_subscription.getDefaultDestinationSection() == person_relative_url\n
person = hosting_subscription.getDefaultDestinationSectionValue()\n
\n
slap_state = hosting_subscription.getSlapState()\n
if (slap_state == \'start_requested\'):\n
person.requestSoftwareInstance(\n
state=\'stopped\',\n
software_release=hosting_subscription.getUrlString(),\n
software_title=hosting_subscription.getTitle(),\n
software_type=hosting_subscription.getSourceReference(),\n
instance_xml=hosting_subscription.getTextContent(),\n
sla_xml=hosting_subscription.getSlaXml(),\n
shared=hosting_subscription.isRootSlave()\n
)\n
return True\n
return False\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>person_relative_url, REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
person = context
ticket_portal_type = "Regularisation Request"
# XXX TODO
# # Prevent to create 2 tickets during the same transaction
# transactional_variable = getTransactionalVariable()
# if tag in transactional_variable:
# raise RuntimeError, 'ticket %s already exist' % tag
# else:
# transactional_variable[tag] = None
ticket = portal.portal_catalog.getResultValue(
portal_type=ticket_portal_type,
default_source_project_uid=person.getUid(),
simulation_state=['suspended', 'validated'],
)
if (ticket is None) and int(person.Entity_statBalance()) > 0:
tag = "%s_addRegularisationRequest_inProgress" % person.getUid()
if (portal.portal_activities.countMessageWithTag(tag) > 0):
# The regularisation request is already under creation but can not be fetched from catalog
# As it is not possible to fetch informations, it is better to raise an error
return None, None
# Prevent concurrent transaction to create 2 tickets for the same person
person.serialize()
# Time to create the ticket
regularisation_request_template = portal.restrictedTraverse(
portal.portal_preferences.getPreferredRegularisationRequestTemplate())
ticket = regularisation_request_template.Base_createCloneDocument(batch_mode=1)
ticket.edit(
source_project_value=context,
title='Account regularisation expected for "%s"' % context.getTitle(),
destination_decision_value=context,
destination_value=context,
start_date=DateTime(),
resource=portal.portal_preferences.getPreferredRegularisationRequestResource(),
)
ticket.validate(comment='New automatic ticket for %s' % context.getTitle())
ticket.suspend(comment='New automatic ticket for %s' % context.getTitle())
ticket.reindexObject(activate_kw={'tag': tag})
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(
reference="slapos-crm.create.regularisation.request")
if notification_message is None:
subject = 'Invoice payment requested'
body = """Dear user,
A new invoice has been generated.
You can access it in your invoice section at %s.
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.
Regards,
The slapos team
""" % portal.portal_preferences.getPreferredSlaposWebSiteUrl()
else:
subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
mail_message = ticket.RegularisationRequest_checkToSendUniqEvent(
portal.portal_preferences.getPreferredRegularisationRequestResource(),
subject,
body,
'Requested manual payment.')
return ticket, mail_message
return ticket, None
......@@ -48,91 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
portal = context.getPortalObject()\n
person = context\n
ticket_portal_type = "Regularisation Request"\n
\n
# XXX TODO\n
# # Prevent to create 2 tickets during the same transaction\n
# transactional_variable = getTransactionalVariable()\n
# if tag in transactional_variable:\n
# raise RuntimeError, \'ticket %s already exist\' % tag\n
# else:\n
# transactional_variable[tag] = None\n
\n
ticket = portal.portal_catalog.getResultValue(\n
portal_type=ticket_portal_type,\n
default_source_project_uid=person.getUid(),\n
simulation_state=[\'suspended\', \'validated\'],\n
)\n
if (ticket is None) and int(person.Entity_statBalance()) > 0:\n
\n
tag = "%s_addRegularisationRequest_inProgress" % person.getUid()\n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
# The regularisation request is already under creation but can not be fetched from catalog\n
# As it is not possible to fetch informations, it is better to raise an error\n
return None, None\n
\n
# Prevent concurrent transaction to create 2 tickets for the same person\n
person.serialize()\n
\n
# Time to create the ticket\n
regularisation_request_template = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredRegularisationRequestTemplate())\n
ticket = regularisation_request_template.Base_createCloneDocument(batch_mode=1)\n
ticket.edit(\n
source_project_value=context,\n
title=\'Account regularisation expected for "%s"\' % context.getTitle(),\n
destination_decision_value=context,\n
destination_value=context,\n
start_date=DateTime(),\n
resource=portal.portal_preferences.getPreferredRegularisationRequestResource(),\n
)\n
ticket.validate(comment=\'New automatic ticket for %s\' % context.getTitle())\n
ticket.suspend(comment=\'New automatic ticket for %s\' % context.getTitle())\n
\n
ticket.reindexObject(activate_kw={\'tag\': tag})\n
\n
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(\n
reference="slapos-crm.create.regularisation.request")\n
if notification_message is None:\n
subject = \'Invoice payment requested\'\n
body = """Dear user,\n
\n
A new invoice has been generated. \n
You can access it in your invoice section at %s.\n
\n
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.\n
\n
Regards,\n
The slapos team\n
""" % portal.portal_preferences.getPreferredSlaposWebSiteUrl()\n
\n
else:\n
subject = notification_message.getTitle()\n
body = notification_message.convert(format=\'text\')[1]\n
\n
mail_message = ticket.RegularisationRequest_checkToSendUniqEvent(\n
portal.portal_preferences.getPreferredRegularisationRequestResource(),\n
subject,\n
body,\n
\'Requested manual payment.\')\n
\n
return ticket, mail_message\n
\n
return ticket, None\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
......@@ -48,11 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>context.RegularisationRequest_init()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
mail_message = None
invoice_list = []
state = context.getSimulationState()
person = context.getSourceProjectValue(portal_type="Person")
if (state != 'suspended') or \
(person is None):
return mail_message, invoice_list
else:
portal = context.getPortalObject()
open_order = portal.portal_catalog.getResultValue(
portal_type="Open Sale Order",
validation_state="validated",
default_destination_decision_uid=person.getUid())
if (open_order is None) or \
(open_order.getValidationState() != "validated") or \
(len(open_order.contentValues(portal_type="Open Sale Order Line")) != 0):
return mail_message, invoice_list
else:
assert open_order.getDestinationDecisionUid() == person.getUid()
ticket = context
for payment in portal.portal_catalog(
portal_type="Payment Transaction",
payment_mode_uid=portal.portal_categories.payment_mode.payzen.getUid(),
default_destination_section_uid=person.getUid(),
simulation_state=["started"],
):
if payment.PaymentTransaction_getPayzenId()[1] is None:
invoice = payment.getCausalityValue(portal_type="Sale Invoice Transaction")
assert payment.getDestinationSectionUid() == person.getUid()
invoice.SaleInvoiceTransaction_createReversalPayzenTransaction()
invoice_list.append(invoice.getRelativeUrl())
# XXX Hardcoded
cancel_service = portal.service_module.slapos_crm_invoice_cancellation
mail_message = ticket.RegularisationRequest_checkToSendUniqEvent(
cancel_service.getRelativeUrl(),
'Cancellation of your bill',
"""Hello,
Thank you to have used our decentralized Cloud Computing service slapos.org.
We noticed that all your instances have been removed upon receiving your bill, so we conclude that the instances that you requested were not being used but probably ordered then forgotten.
To not to charge our first users a "non use" of our service, we have choosen to cancel your bill. That's mean: *You have nothing to pay us.*
We hope to see you using our services in the future.
Regards,
The slapos team
""",
'Cancelled payment.')
return mail_message, invoice_list
......@@ -48,72 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
mail_message = None\n
invoice_list = []\n
\n
state = context.getSimulationState()\n
person = context.getSourceProjectValue(portal_type="Person")\n
if (state != \'suspended\') or \\\n
(person is None):\n
return mail_message, invoice_list\n
else:\n
portal = context.getPortalObject()\n
\n
open_order = portal.portal_catalog.getResultValue(\n
portal_type="Open Sale Order",\n
validation_state="validated",\n
default_destination_decision_uid=person.getUid())\n
\n
if (open_order is None) or \\\n
(open_order.getValidationState() != "validated") or \\\n
(len(open_order.contentValues(portal_type="Open Sale Order Line")) != 0):\n
return mail_message, invoice_list\n
else:\n
assert open_order.getDestinationDecisionUid() == person.getUid()\n
ticket = context\n
\n
for payment in portal.portal_catalog(\n
portal_type="Payment Transaction", \n
payment_mode_uid=portal.portal_categories.payment_mode.payzen.getUid(),\n
default_destination_section_uid=person.getUid(),\n
simulation_state=["started"],\n
):\n
\n
if payment.PaymentTransaction_getPayzenId()[1] is None:\n
invoice = payment.getCausalityValue(portal_type="Sale Invoice Transaction")\n
assert payment.getDestinationSectionUid() == person.getUid()\n
invoice.SaleInvoiceTransaction_createReversalPayzenTransaction()\n
invoice_list.append(invoice.getRelativeUrl())\n
\n
# XXX Hardcoded\n
cancel_service = portal.service_module.slapos_crm_invoice_cancellation\n
mail_message = ticket.RegularisationRequest_checkToSendUniqEvent(\n
cancel_service.getRelativeUrl(),\n
\'Cancellation of your bill\',\n
"""Hello,\n
\n
Thank you to have used our decentralized Cloud Computing service slapos.org.\n
\n
We noticed that all your instances have been removed upon receiving your bill, so we conclude that the instances that you requested were not being used but probably ordered then forgotten.\n
\n
To not to charge our first users a "non use" of our service, we have choosen to cancel your bill. That\'s mean: *You have nothing to pay us.*\n
\n
We hope to see you using our services in the future.\n
\n
Regards,\n
The slapos team\n
""",\n
\'Cancelled payment.\')\n
\n
return mail_message, invoice_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
ticket = context
service = portal.restrictedTraverse(service_relative_url)
assert service.getPortalType() == "Service"
event_portal_type = "Mail Message"
# XXX TODO
# # Prevent to create 2 tickets during the same transaction
# transactional_variable = getTransactionalVariable()
# if tag in transactional_variable:
# raise RuntimeError, 'ticket %s already exist' % tag
# else:
# transactional_variable[tag] = None
event = portal.portal_catalog.getResultValue(
portal_type=event_portal_type,
default_resource_uid=service.getUid(),
default_follow_up_uid=ticket.getUid(),
)
if (event is None) and (ticket.getSimulationState() == 'suspended'):
tag = "%s_addUniqEvent_%s" % (ticket.getUid(), service.getUid())
if (portal.portal_activities.countMessageWithTag(tag) > 0):
# The event is already under creation but can not be fetched from catalog
return None
# Prevent concurrent transaction to create 2 events for the same ticket
ticket.edit(resource=service_relative_url)
event = portal.event_module.newContent(
portal_type=event_portal_type,
start_date=DateTime(),
destination=ticket.getDestination(),
follow_up=ticket.getRelativeUrl(),
source=context.getSource(),
title=title,
resource=service_relative_url,
text_content=text_content,
)
portal.portal_workflow.doActionFor(event, 'start_action', send_mail=True, comment=comment)
event.stop(comment=comment)
event.deliver(comment=comment)
event.reindexObject(activate_kw={'tag': tag})
return event
......@@ -48,64 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
portal = context.getPortalObject()\n
ticket = context\n
service = portal.restrictedTraverse(service_relative_url)\n
assert service.getPortalType() == "Service"\n
event_portal_type = "Mail Message"\n
\n
# XXX TODO\n
# # Prevent to create 2 tickets during the same transaction\n
# transactional_variable = getTransactionalVariable()\n
# if tag in transactional_variable:\n
# raise RuntimeError, \'ticket %s already exist\' % tag\n
# else:\n
# transactional_variable[tag] = None\n
\n
event = portal.portal_catalog.getResultValue(\n
portal_type=event_portal_type,\n
default_resource_uid=service.getUid(),\n
default_follow_up_uid=ticket.getUid(),\n
)\n
\n
if (event is None) and (ticket.getSimulationState() == \'suspended\'):\n
tag = "%s_addUniqEvent_%s" % (ticket.getUid(), service.getUid())\n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
# The event is already under creation but can not be fetched from catalog\n
return None\n
\n
# Prevent concurrent transaction to create 2 events for the same ticket\n
ticket.edit(resource=service_relative_url)\n
\n
event = portal.event_module.newContent(\n
portal_type=event_portal_type,\n
start_date=DateTime(),\n
destination=ticket.getDestination(),\n
follow_up=ticket.getRelativeUrl(),\n
source=context.getSource(),\n
title=title,\n
resource=service_relative_url,\n
text_content=text_content,\n
)\n
\n
portal.portal_workflow.doActionFor(event, \'start_action\', send_mail=True, comment=comment)\n
event.stop(comment=comment)\n
event.deliver(comment=comment)\n
event.reindexObject(activate_kw={\'tag\': tag})\n
\n
return event\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>service_relative_url, title, text_content, comment, REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
ticket = context
current_service = portal.restrictedTraverse(current_service_relative_url)
assert current_service.getPortalType() == "Service"
event_portal_type = "Mail Message"
event = portal.portal_catalog.getResultValue(
portal_type=event_portal_type,
default_resource_uid=current_service.getUid(),
default_follow_up_uid=ticket.getUid(),
simulation_state="delivered",
)
if (ticket.getSimulationState() == 'suspended') and (event is not None) and (ticket.getResource() == current_service_relative_url):
if (DateTime() - event.getStartDate()) > delay_period_in_days:
ticket.RegularisationRequest_checkToSendUniqEvent(next_service_relative_url, title, text_content, comment)
return event.getRelativeUrl()
return None
......@@ -48,38 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
portal = context.getPortalObject()\n
ticket = context\n
current_service = portal.restrictedTraverse(current_service_relative_url)\n
assert current_service.getPortalType() == "Service"\n
\n
event_portal_type = "Mail Message"\n
\n
event = portal.portal_catalog.getResultValue(\n
portal_type=event_portal_type,\n
default_resource_uid=current_service.getUid(),\n
default_follow_up_uid=ticket.getUid(),\n
simulation_state="delivered",\n
)\n
\n
if (ticket.getSimulationState() == \'suspended\') and (event is not None) and (ticket.getResource() == current_service_relative_url):\n
if (DateTime() - event.getStartDate()) > delay_period_in_days:\n
ticket.RegularisationRequest_checkToSendUniqEvent(next_service_relative_url, title, text_content, comment)\n
return event.getRelativeUrl()\n
\n
return None\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>delay_period_in_days, current_service_relative_url, next_service_relative_url, title, text_content, comment, REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
ticket = context
state = ticket.getSimulationState()
person = ticket.getSourceProjectValue(portal_type="Person")
if (state == 'suspended') and \
(person is not None) and \
(ticket.getResource() == 'service_module/slapos_crm_delete_acknowledgement'):
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Hosting Subscription",
validation_state=["validated"],
default_destination_section_uid=person.getUid(),
method_id='HostingSubscription_deleteFromRegularisationRequest',
method_args=(person.getRelativeUrl(),),
activate_kw={'tag': tag}
)
return True
return False
......@@ -48,32 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
ticket = context\n
state = ticket.getSimulationState()\n
person = ticket.getSourceProjectValue(portal_type="Person")\n
if (state == \'suspended\') and \\\n
(person is not None) and \\\n
(ticket.getResource() == \'service_module/slapos_crm_delete_acknowledgement\'):\n
\n
portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Hosting Subscription",\n
validation_state=["validated"],\n
default_destination_section_uid=person.getUid(),\n
method_id=\'HostingSubscription_deleteFromRegularisationRequest\',\n
method_args=(person.getRelativeUrl(),),\n
activate_kw={\'tag\': tag}\n
)\n
return True\n
return False\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, REQUEST=None</string> </value>
......
......@@ -48,11 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.Ticket_getResourceItemList()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
# Define Reference from ID provided by portal_ids
portal = context.getPortalObject()
type_definition = context.getTypeInfo()
short_portal_type = type_definition.getShortTitle()
if not short_portal_type:
short_portal_type = ''.join(s for s in type_definition.getId() if s.isupper())
id_group = ('reference', short_portal_type)
default = 1
new_id = portal.portal_ids.generateNewId(id_group=id_group, default=default)
reference = '%s-%s' % (short_portal_type, new_id)
context.setReference(reference)
......@@ -48,24 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># Define Reference from ID provided by portal_ids\n
portal = context.getPortalObject()\n
type_definition = context.getTypeInfo()\n
\n
short_portal_type = type_definition.getShortTitle()\n
if not short_portal_type:\n
short_portal_type = \'\'.join(s for s in type_definition.getId() if s.isupper())\n
\n
id_group = (\'reference\', short_portal_type)\n
default = 1\n
new_id = portal.portal_ids.generateNewId(id_group=id_group, default=default)\n
reference = \'%s-%s\' % (short_portal_type, new_id)\n
\n
context.setReference(reference)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
state = context.getSimulationState()
person = context.getSourceProjectValue(portal_type="Person")
if (state != 'suspended') or \
(person is None) or \
(int(person.Entity_statBalance()) > 0):
return
else:
context.invalidate(comment="Automatically disabled as balance is %s" % person.Entity_statBalance())
......@@ -48,26 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
state = context.getSimulationState()\n
person = context.getSourceProjectValue(portal_type="Person")\n
if (state != \'suspended\') or \\\n
(person is None) or \\\n
(int(person.Entity_statBalance()) > 0):\n
return\n
else:\n
context.invalidate(comment="Automatically disabled as balance is %s" % person.Entity_statBalance())\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
ticket = context
state = ticket.getSimulationState()
person = ticket.getSourceProjectValue(portal_type="Person")
if (state == 'suspended') and \
(person is not None) and \
(ticket.getResource() in ['service_module/slapos_crm_stop_acknowledgement', 'service_module/slapos_crm_delete_reminder']):
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Hosting Subscription",
validation_state=["validated"],
default_destination_section_uid=person.getUid(),
method_id='HostingSubscription_stopFromRegularisationRequest',
method_args=(person.getRelativeUrl(),),
activate_kw={'tag': tag}
)
return True
return False
......@@ -48,32 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
ticket = context\n
state = ticket.getSimulationState()\n
person = ticket.getSourceProjectValue(portal_type="Person")\n
if (state == \'suspended\') and \\\n
(person is not None) and \\\n
(ticket.getResource() in [\'service_module/slapos_crm_stop_acknowledgement\', \'service_module/slapos_crm_delete_reminder\']):\n
\n
portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Hosting Subscription",\n
validation_state=["validated"],\n
default_destination_section_uid=person.getUid(),\n
method_id=\'HostingSubscription_stopFromRegularisationRequest\',\n
method_args=(person.getRelativeUrl(),),\n
activate_kw={\'tag\': tag}\n
)\n
return True\n
return False\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.acknowledgment.escalation")
if notification_message is None:
subject = 'Reminder: invoice payment requested'
body = """Dear user,
We would like to remind you the unpaid invoice you have on %s.
If no payment is done during the coming days, we will stop all your current instances to free some hardware resources.
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.
Regards,
The slapos team
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()
else:
subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
return context.RegularisationRequest_checkToTriggerNextEscalationStep(
38,
'service_module/slapos_crm_acknowledgement',
'service_module/slapos_crm_stop_reminder',
subject,
body,
'Stopping reminder.',
)
......@@ -48,40 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.acknowledgment.escalation")\n
if notification_message is None:\n
subject = \'Reminder: invoice payment requested\'\n
body = """Dear user,\n
\n
We would like to remind you the unpaid invoice you have on %s.\n
If no payment is done during the coming days, we will stop all your current instances to free some hardware resources.\n
\n
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.\n
\n
Regards,\n
The slapos team\n
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()\n
\n
else:\n
subject = notification_message.getTitle()\n
body = notification_message.convert(format=\'text\')[1]\n
\n
return context.RegularisationRequest_checkToTriggerNextEscalationStep(\n
38,\n
\'service_module/slapos_crm_acknowledgement\',\n
\'service_module/slapos_crm_stop_reminder\',\n
subject,\n
body,\n
\'Stopping reminder.\',\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.delete.reminder.escalation")
if notification_message is None:
subject = 'Acknowledgment: instances deleted'
body = """Dear user,
Despite our last reminder, you still have an unpaid invoice on %s.
We will now delete all your instances.
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.
Regards,
The slapos team
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()
else:
subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
return context.RegularisationRequest_checkToTriggerNextEscalationStep(
2,
'service_module/slapos_crm_delete_reminder',
'service_module/slapos_crm_delete_acknowledgement',
subject,
body,
'Deleting acknowledgment.',
)
......@@ -48,39 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.delete.reminder.escalation")\n
if notification_message is None:\n
subject = \'Acknowledgment: instances deleted\'\n
body = """Dear user,\n
\n
Despite our last reminder, you still have an unpaid invoice on %s.\n
We will now delete all your instances.\n
\n
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.\n
\n
Regards,\n
The slapos team\n
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()\n
else:\n
subject = notification_message.getTitle()\n
body = notification_message.convert(format=\'text\')[1]\n
\n
return context.RegularisationRequest_checkToTriggerNextEscalationStep(\n
2,\n
\'service_module/slapos_crm_delete_reminder\',\n
\'service_module/slapos_crm_delete_acknowledgement\',\n
subject,\n
body,\n
\'Deleting acknowledgment.\',\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.stop.acknowledgment.escalation")
if notification_message is None:
subject = 'Last reminder: invoice payment requested'
body = """Dear user,
We would like to remind you the unpaid invoice you have on %s.
If no payment is done during the coming days, we will delete all your instances.
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.
Regards,
The slapos team
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()
else:
subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
return context.RegularisationRequest_checkToTriggerNextEscalationStep(
13,
'service_module/slapos_crm_stop_acknowledgement',
'service_module/slapos_crm_delete_reminder',
subject,
body,
'Deleting reminder.',
)
......@@ -48,39 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.stop.acknowledgment.escalation")\n
if notification_message is None:\n
subject = \'Last reminder: invoice payment requested\'\n
body = """Dear user,\n
\n
We would like to remind you the unpaid invoice you have on %s.\n
If no payment is done during the coming days, we will delete all your instances.\n
\n
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.\n
\n
Regards,\n
The slapos team\n
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()\n
else:\n
subject = notification_message.getTitle()\n
body = notification_message.convert(format=\'text\')[1]\n
\n
return context.RegularisationRequest_checkToTriggerNextEscalationStep(\n
13,\n
\'service_module/slapos_crm_stop_acknowledgement\',\n
\'service_module/slapos_crm_delete_reminder\',\n
subject,\n
body,\n
\'Deleting reminder.\',\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.stop.reminder.escalation")
if notification_message is None:
subject = 'Acknowledgment: instances stopped'
body = """Dear user,
Despite our last reminder, you still have an unpaid invoice on %s.
We will now stop all your current instances to free some hardware resources.
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.
Regards,
The slapos team
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()
else:
subject = notification_message.getTitle()
body = notification_message.convert(format='text')[1]
return context.RegularisationRequest_checkToTriggerNextEscalationStep(
7,
'service_module/slapos_crm_stop_reminder',
'service_module/slapos_crm_stop_acknowledgement',
subject,
body,
'Stopping acknowledgment.',
)
......@@ -48,39 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
notification_message = context.getPortalObject().portal_notifications.getDocumentValue(reference="slapos-crm.stop.reminder.escalation")\n
if notification_message is None:\n
subject = \'Acknowledgment: instances stopped\'\n
body = """Dear user,\n
\n
Despite our last reminder, you still have an unpaid invoice on %s.\n
We will now stop all your current instances to free some hardware resources.\n
\n
Do not hesitate to visit the web forum (http://community.slapos.org/forum) in case of question.\n
\n
Regards,\n
The slapos team\n
""" % context.getPortalObject().portal_preferences.getPreferredSlaposWebSiteUrl()\n
else:\n
subject = notification_message.getTitle()\n
body = notification_message.convert(format=\'text\')[1]\n
\n
return context.RegularisationRequest_checkToTriggerNextEscalationStep(\n
7,\n
\'service_module/slapos_crm_stop_reminder\',\n
\'service_module/slapos_crm_stop_acknowledgement\',\n
subject,\n
body,\n
\'Stopping acknowledgment.\',\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
......@@ -18,36 +18,6 @@
<key> <string>content_type</string> </key>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="base64">iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
bWFnZVJlYWR5ccllPAAABYhJREFUeNrEV1tsFFUY/uayM73ssu1ut+XSSlu2VaklRhpME6JoojEk
ShAxURONIUQf0MRgvD0Q8QFfRHznQZFgIuqDDyCo4aImXBRRatpqkLawW1qkSNtlL7M7c/zP3HZm
L4VECGf3yzlzZub83/n+//znjMAYw+0sgkPgzPvRfqq2E/pvsc1jhM3L3p7iNWSnlxns04Vt6Xjk
nqcsZvUdgBK9/nB67oasspkBs77yx5f94xfq9lCz00fAMBBvJOMMIoz0BbCrvwFiDUEt1pJqXyvE
kCAGqKYhBPH6Ute0Q8gmwW0kxvZ3OP1FBcgTLJ2EoU2DZScsI2KejBLEAtmg2rDaFnQbDgk+lFBd
AW2WJqdCTI/CG3ZFBXQGI5Wg2SdN47VrkvSC8yQzGbLCDFhmgga7TGTPw5g6DpafthVxyEhzyKBa
NnRWgYBB7pw5Z81CZGYlMMEmIVj/QJgmOo+uu8EoZqW2p8Fmz0Kf/B7Gv6esQUSuBidSWQ1uwzDm
VSJApnR7trpWNOoI4M7C8pcAwaIW6oIcjMOYHkBhdA+pc5U6HSJyuSt0y5ZTRJ8L+E0bHt3sv+C5
tuD8eFts6EWg9z2IjcvJVRlCzgKpwhhcWONXcQHzGP5ha9GXAvk2uOA+yDUNiMQfRdPSdVBCi2w1
3IrcryIQ30iBG0IhedCKCckgfrLVdhWoFoQeAsvaPLKxPLL5E9BTMmaPH0HiyLuo73gEHQ9tQV2s
x85o9rPEJtD5DK2mGegTP5pTZp4gLVXA5wLOrhJAjGtIkHqpgJZ6Dd2xHMJXDmDok1UYPbTVlLnU
LWr3BkpkTRQTaQK5JJ8FuEuqEdA9/p8bpFReQ52YQ0djBvmBjzC49znqSxfjw3ab2vsajEKe1LhG
BNJUp80xdL2KC1iheKNpk/WUkfkHxswI8onD0M4fRD551KFsShNRDKQm92Po8+fR8+wXNCXRzUdy
qB2BO9ZA++szMIoPgRTkNiorYKDiKhBrY5BbVqB2+ZsIrz2E8LqfIDX3e9TIm2rUTR7A3we32KtF
cNVQOtfSczqMXMqCbtmqsgyLqFYCC/rRuP6oSch9vqCbJLKnPsDM+GmyK7hEJFo5gfYnYGRnad9K
lY0vlrrAwdw7i4TQym2o73vL905ULWBs3ztluUPtXk+uTJkodYFcGoRO+WaTxU1Sg4gsWYnFq15F
bOljPh6hB7ZBmxxA9uy+okLj32J67CTCi1e4mVQJtUKK9CB/6feyIKy6DHvnW7irIYXgxQMY3rka
w1+9TnJrfhIP7+Am3PeCNKXLp/eWZVI09ZEbrlVfhqWp2A1GCpg6GnRxA5A+/iEGdm/0EVCicahd
a33vaCOHSn0GMdZLMZCZIxEZ/uSjtj2I+S/9aoK3eV+0lu4N7salM/t8w8tLHve9K04NUnLybShQ
o120CnJlqbiqApEnd0GZf68J3nb6w5RVLx7e4R+8dYXv3QDTkJue8CsVXkRLtjDXZsR8m5HOJAQ8
be89efyYf2kGY7771oT8scKD2XnGux37dkMl1onc5DnzemDXy1j24k7rxPzxRkQ9siksg69fKJ4D
JQqyu5v9BI6+sQSa7gtF9LSQWi2dMIbPV0nFenFLlmlpfffKQrPdGqZ+pWSwpvKDhrd0NaLiYYRV
cwE/LMjzaBqSgmxiGEHS/07PqZwZ//+DQG1uN20wNlbRBWdHfj4Rb++7HwrJpERbEWhovilfIvmr
l6BNJSCHm0E2yJY4UkZAK7ANQwlh+5/Jk31Wz+gt+CgahcGEX3TGNpd9mgmCuZHzwA8SIjzJmSlu
rsP+jRVugC+JWf5hREhxUZht2EvAyQvcaC13GQ/wm0SAhyj/hsvYZAzXbgkBh4QD4SZpz6yk7gJl
BG5X+U+AAQB5+ylwOFuBFAAAAABJRU5ErkJggg==</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>32</int> </value>
......
portal = context.getPortalObject()
category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)
category_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)
if category_public is not None:
portal.portal_catalog.searchAndActivate(
portal_type='Computer',
default_allocation_scope_uid=[category_public.getUid(), category_friend.getUid()],
validation_state="validated",
method_id='Computer_checkAndUpdateAllocationScope',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,25 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)\n
category_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)\n
\n
if category_public is not None:\n
portal.portal_catalog.searchAndActivate(\n
portal_type=\'Computer\',\n
default_allocation_scope_uid=[category_public.getUid(), category_friend.getUid()],\n
validation_state="validated",\n
method_id=\'Computer_checkAndUpdateAllocationScope\',\n
activate_kw={\'tag\': tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
category_personal = portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None)
if category_personal is not None:
portal.portal_catalog.searchAndActivate(
portal_type='Computer',
validation_state='validated',
modification_date=(DateTime() - 30).strftime('<=%Y/%m/%d'),
default_allocation_scope_uid=category_personal.getUid(),
left_join_list=['aggregate_related_uid'],
aggregate_related_uid=None,
method_id='Computer_checkAndUpdatePersonalAllocationScope',
activate_kw={'tag': tag})
context.activate(after_tag=tag).getId()
......@@ -48,30 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
\n
category_personal = portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None)\n
\n
if category_personal is not None:\n
portal.portal_catalog.searchAndActivate(\n
portal_type=\'Computer\', \n
validation_state=\'validated\', \n
modification_date=(DateTime() - 30).strftime(\'<=%Y/%m/%d\'), \n
default_allocation_scope_uid=category_personal.getUid(), \n
left_join_list=[\'aggregate_related_uid\'], \n
aggregate_related_uid=None,\n
method_id=\'Computer_checkAndUpdatePersonalAllocationScope\',\n
activate_kw={\'tag\': tag})\n
\n
context.activate(after_tag=tag).getId()\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......@@ -83,4 +59,4 @@ context.activate(after_tag=tag).getId()\n
</dictionary>
</pickle>
</record>
</ZopeData>
\ No newline at end of file
</ZopeData>
portal = context.getPortalObject()
public_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/public", None).getUid()
friend_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/friend", None).getUid()
if None not in [friend_category_uid, public_category_uid]:
portal.portal_catalog.searchAndActivate(
portal_type = 'Computer',
validation_state = 'validated',
default_allocation_scope_uid = [public_category_uid, friend_category_uid],
method_id = 'Computer_checkState',
activate_kw = {'tag':tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,28 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
public_category_uid = portal.restrictedTraverse(\n
"portal_categories/allocation_scope/open/public", None).getUid()\n
\n
friend_category_uid = portal.restrictedTraverse(\n
"portal_categories/allocation_scope/open/friend", None).getUid()\n
\n
\n
if None not in [friend_category_uid, public_category_uid]:\n
portal.portal_catalog.searchAndActivate(\n
portal_type = \'Computer\',\n
validation_state = \'validated\',\n
default_allocation_scope_uid = [public_category_uid, friend_category_uid],\n
method_id = \'Computer_checkState\',\n
activate_kw = {\'tag\':tag} \n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type='Hosting Subscription',
validation_state='validated',
method_id='HostingSubscription_checkSofwareInstanceState',
activate_kw = {'tag':tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,20 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
portal.portal_catalog.searchAndActivate(\n
portal_type=\'Hosting Subscription\',\n
validation_state=\'validated\',\n
method_id=\'HostingSubscription_checkSofwareInstanceState\',\n
activate_kw = {\'tag\':tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
from DateTime import DateTime
portal = context.getPortalObject()
source_project_value = portal.restrictedTraverse(source_relative_url)
if source_project_value.getPortalType() == "Computer":
destination_decision = source_project_value.getSourceAdministration()
elif source_project_value.getPortalType() == "Software Instance":
destination_decision = source_project_value.getSpecialiseValue().getDestinationSection()
elif source_project_value.getPortalType() == "Hosting Subscription":
destination_decision = source_project_value.getDestinationSection()
elif source_project_value.getPortalType() == "Software Installation":
destination_decision = source_project_value.getDestinationSection()
else:
destination_decision = None
if portal.ERP5Site_isSupportRequestCreationClosed(destination_decision):
# Stop ticket creation
return
support_request_in_progress = portal.portal_catalog.getResultValue(
portal_type = 'Support Request',
title = title,
simulation_state = ["validated", "submitted", "suspended"],
source_project_uid = source_project_value.getUid(),
)
if support_request_in_progress is not None:
return support_request_in_progress
support_request_in_progress = context.REQUEST.get("support_request_in_progress", None)
if support_request_in_progress is not None:
return portal.restrictedTraverse(support_request_in_progress)
resource = portal.service_module.\
slapos_crm_monitoring.getRelativeUrl()
support_request = portal.\
support_request_module.\
slapos_crm_support_request_template_for_monitoring.\
Base_createCloneDocument(batch_mode=1)
support_request.edit(
title = title,
description = description,
start_date = DateTime(),
destination_decision=destination_decision,
source_project_value = source_project_value,
resource=resource
)
support_request.validate()
context.REQUEST.set("support_request_in_progress", support_request.getRelativeUrl())
return support_request
......@@ -48,65 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
\n
portal = context.getPortalObject()\n
source_project_value = portal.restrictedTraverse(source_relative_url)\n
\n
if source_project_value.getPortalType() == "Computer":\n
destination_decision = source_project_value.getSourceAdministration()\n
elif source_project_value.getPortalType() == "Software Instance":\n
destination_decision = source_project_value.getSpecialiseValue().getDestinationSection()\n
elif source_project_value.getPortalType() == "Hosting Subscription":\n
destination_decision = source_project_value.getDestinationSection()\n
elif source_project_value.getPortalType() == "Software Installation":\n
destination_decision = source_project_value.getDestinationSection()\n
else:\n
destination_decision = None\n
\n
if portal.ERP5Site_isSupportRequestCreationClosed(destination_decision):\n
# Stop ticket creation\n
return\n
\n
support_request_in_progress = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n
title = title,\n
simulation_state = ["validated", "submitted", "suspended"],\n
source_project_uid = source_project_value.getUid(),\n
)\n
\n
if support_request_in_progress is not None:\n
return support_request_in_progress\n
\n
support_request_in_progress = context.REQUEST.get("support_request_in_progress", None)\n
\n
if support_request_in_progress is not None:\n
return portal.restrictedTraverse(support_request_in_progress)\n
\n
resource = portal.service_module.\\\n
slapos_crm_monitoring.getRelativeUrl()\n
\n
support_request = portal.\\\n
support_request_module.\\\n
slapos_crm_support_request_template_for_monitoring.\\\n
Base_createCloneDocument(batch_mode=1)\n
support_request.edit(\n
title = title,\n
description = description,\n
start_date = DateTime(),\n
destination_decision=destination_decision,\n
source_project_value = source_project_value,\n
resource=resource\n
)\n
support_request.validate()\n
\n
context.REQUEST.set("support_request_in_progress", support_request.getRelativeUrl())\n
\n
return support_request\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, description, source_relative_url</string> </value>
......
from DateTime import DateTime
computer = context
portal = context.getPortalObject()
allocation_scope = computer.getAllocationScope()
computer_reference = computer.getReference()
if allocation_scope not in ['open/public', 'open/friend', 'open/personal']:
return
if allocation_scope == target_allocation_scope:
# already changed
return
person = computer.getSourceAdministrationValue(portal_type="Person")
if not person:
return
if not person.Person_isServiceProvider():
edit_kw = {
'allocation_scope': target_allocation_scope,
}
# Create a ticket (or re-open it) for this issue!
request_title = 'We have changed allocation scope for %s' % computer_reference
request_description = 'Allocation scope has been changed to ' \
'%s for %s' % (target_allocation_scope, computer_reference)
support_request = context.Base_generateSupportRequestForSlapOS(
request_title,
request_description,
computer.getRelativeUrl()
)
if support_request.getSimulationState() != "validated":
support_request.validate()
# Send notification message
message = request_description
notification_message = portal.portal_notifications.getDocumentValue(
reference=notification_message_reference)
if notification_message is not None:
mapping_dict = {'computer_title':computer.getTitle(),
'computer_id':computer_reference,
'allocation_scope':allocation_scope}
message = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict': mapping_dict})
event = support_request.SupportRequest_trySendNotificationMessage(
request_title, message, person.getRelativeUrl())
if event is not None:
computer.edit(**edit_kw)
return support_request
......@@ -48,67 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
\n
computer = context\n
portal = context.getPortalObject()\n
allocation_scope = computer.getAllocationScope()\n
computer_reference = computer.getReference()\n
\n
if allocation_scope not in [\'open/public\', \'open/friend\', \'open/personal\']:\n
return\n
\n
if allocation_scope == target_allocation_scope:\n
# already changed\n
return\n
\n
person = computer.getSourceAdministrationValue(portal_type="Person")\n
if not person:\n
return\n
\n
if not person.Person_isServiceProvider():\n
edit_kw = {\n
\'allocation_scope\': target_allocation_scope,\n
}\n
\n
# Create a ticket (or re-open it) for this issue!\n
request_title = \'We have changed allocation scope for %s\' % computer_reference\n
request_description = \'Allocation scope has been changed to \' \\\n
\'%s for %s\' % (target_allocation_scope, computer_reference)\n
\n
support_request = context.Base_generateSupportRequestForSlapOS(\n
request_title,\n
request_description,\n
computer.getRelativeUrl()\n
)\n
\n
if support_request.getSimulationState() != "validated":\n
support_request.validate()\n
\n
# Send notification message\n
message = request_description\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=notification_message_reference)\n
\n
if notification_message is not None:\n
mapping_dict = {\'computer_title\':computer.getTitle(),\n
\'computer_id\':computer_reference,\n
\'allocation_scope\':allocation_scope}\n
\n
message = notification_message.asText(\n
substitution_method_parameter_dict={\'mapping_dict\': mapping_dict})\n
\n
event = support_request.SupportRequest_trySendNotificationMessage(\n
request_title, message, person.getRelativeUrl())\n
\n
if event is not None:\n
computer.edit(**edit_kw)\n
\n
return support_request\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>target_allocation_scope=\'open/personal\', notification_message_reference=\'slapos-crm-computer_allocation_scope.notification\'</string> </value>
......
return context.Computer_checkAndUpdateAllocationScope(
target_allocation_scope = 'close/termination',
notification_message_reference='slapos-crm-computer_personal_allocation_scope.notification')
......@@ -48,13 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.Computer_checkAndUpdateAllocationScope(\n
target_allocation_scope = \'close/termination\',\n
notification_message_reference=\'slapos-crm-computer_personal_allocation_scope.notification\')\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
from DateTime import DateTime
import json
portal = context.getPortalObject()
if portal.ERP5Site_isSupportRequestCreationClosed():
# Stop ticket creation
return
reference = context.getReference()
computer_title = context.getTitle()
ticket_title = "[MONITORING] Lost contact with computer %s" % reference
description = ""
should_notify = True
last_contact = "No Contact Information"
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
try:
d = memcached_dict[reference]
d = json.loads(d)
last_contact = DateTime(d.get('created_at'))
if (DateTime() - last_contact) > 0.01:
description = "The Computer %s (%s) has not contacted the server for more than 30 minutes" \
"(last contact date: %s)" % (computer_title, reference, last_contact)
else:
should_notify = False
except KeyError:
ticket_title = "[MONITORING] No information about %s" % reference
description = "The Computer %s (%s) has not contacted the server (No Contact Information)" % (
computer_title, reference)
if should_notify:
support_request = context.Base_generateSupportRequestForSlapOS(
ticket_title,
description,
context.getRelativeUrl()
)
person = context.getSourceAdministrationValue(portal_type="Person")
if not person:
return support_request
# Send Notification message
notification_reference = 'slapos-crm-computer_check_state.notification'
notification_message = portal.portal_notifications.getDocumentValue(
reference=notification_reference)
if notification_message is None:
message = """%s""" % description
else:
mapping_dict = {'computer_title':context.getTitle(),
'computer_id':reference,
'last_contact':last_contact}
message = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':mapping_dict})
support_request.SupportRequest_trySendNotificationMessage(
ticket_title,
message, person.getRelativeUrl())
return support_request
......@@ -48,78 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from DateTime import DateTime\n
import json\n
\n
portal = context.getPortalObject()\n
\n
if portal.ERP5Site_isSupportRequestCreationClosed():\n
# Stop ticket creation\n
return\n
\n
reference = context.getReference()\n
computer_title = context.getTitle()\n
ticket_title = "[MONITORING] Lost contact with computer %s" % reference\n
description = ""\n
should_notify = True\n
last_contact = "No Contact Information"\n
\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
\n
try:\n
d = memcached_dict[reference]\n
d = json.loads(d)\n
last_contact = DateTime(d.get(\'created_at\'))\n
if (DateTime() - last_contact) > 0.01:\n
description = "The Computer %s (%s) has not contacted the server for more than 30 minutes" \\\n
"(last contact date: %s)" % (computer_title, reference, last_contact)\n
else:\n
should_notify = False\n
except KeyError:\n
ticket_title = "[MONITORING] No information about %s" % reference\n
description = "The Computer %s (%s) has not contacted the server (No Contact Information)" % (\n
computer_title, reference)\n
\n
if should_notify:\n
support_request = context.Base_generateSupportRequestForSlapOS(\n
ticket_title,\n
description,\n
context.getRelativeUrl()\n
)\n
\n
person = context.getSourceAdministrationValue(portal_type="Person")\n
if not person:\n
return support_request\n
\n
# Send Notification message\n
notification_reference = \'slapos-crm-computer_check_state.notification\'\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=notification_reference)\n
\n
if notification_message is None:\n
message = """%s""" % description\n
else:\n
mapping_dict = {\'computer_title\':context.getTitle(),\n
\'computer_id\':reference,\n
\'last_contact\':last_contact}\n
message = notification_message.asText(\n
substitution_method_parameter_dict={\'mapping_dict\':mapping_dict})\n
\n
support_request.SupportRequest_trySendNotificationMessage(\n
ticket_title,\n
message, person.getRelativeUrl())\n
\n
return support_request\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
# HARDCODED LIMIT TO BE MOVED TO GLOBAL PREFERENCES
limit = 5
kw['limit'] = limit
kw['portal_type'] = 'Support Request'
kw['simulation_state'] = ["validated","submitted"]
if destination_decision:
kw['default_destination_decision_uid'] = context.restrictedTraverse(
destination_decision).getUid()
support_request_list = context.portal_catalog(**kw)
return len(support_request_list) >= limit
......@@ -48,27 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# HARDCODED LIMIT TO BE MOVED TO GLOBAL PREFERENCES\n
limit = 5\n
\n
kw[\'limit\'] = limit\n
kw[\'portal_type\'] = \'Support Request\'\n
kw[\'simulation_state\'] = ["validated","submitted"]\n
if destination_decision:\n
kw[\'default_destination_decision_uid\'] = context.restrictedTraverse(\n
destination_decision).getUid()\n
\n
support_request_list = context.portal_catalog(**kw)\n
\n
return len(support_request_list) >= limit\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>destination_decision=None, **kw</string> </value>
......
kw['simulation_state'] = ['validated','submitted']
kw['sort_on'] = [('modification_date', 'DESC'),]
return context.searchFolder(**kw)
......@@ -48,13 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>kw[\'simulation_state\'] = [\'validated\',\'submitted\']\n
kw[\'sort_on\'] = [(\'modification_date\', \'DESC\'),]\n
return context.searchFolder(**kw)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate
hosting_subscription = context
portal = context.getPortalObject()
if portal.ERP5Site_isSupportRequestCreationClosed():
# Stop ticket creation
return
date_check_limit = addToDate(DateTime(), to_add={'hour': -1})
if (date_check_limit - hosting_subscription.getCreationDate()) < 0:
# Too early to check
return
#if not source_instance:
# return
software_instance_list = hosting_subscription.getSpecialiseRelatedValueList(
portal_type=["Software Instance", "Slave Instance"])
has_newest_allocated_instance = False
has_unallocated_instance = False
failing_instance = None
# Check if at least one software Instance is Allocated
for instance in software_instance_list:
if instance.getSlapState() not in ["start_requested", "stop_requested"]:
continue
if (date_check_limit - instance.getCreationDate()) < 0:
continue
if instance.getAggregateValue() is not None:
has_newest_allocated_instance = True
if instance.getPortalType() == "Software Instance" and \
instance.SoftwareInstance_hasReportedError():
return context.HostingSubscription_createSupportRequestEvent(
instance, 'slapos-crm-hosting-subscription-instance-state.notification')
else:
has_unallocated_instance = True
failing_instance = instance
if has_unallocated_instance and has_newest_allocated_instance:
return context.HostingSubscription_createSupportRequestEvent(
failing_instance, 'slapos-crm-hosting-subscription-instance-allocation.notification')
return
......@@ -48,63 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from DateTime import DateTime\n
from Products.ERP5Type.DateUtils import addToDate\n
\n
hosting_subscription = context\n
portal = context.getPortalObject()\n
\n
if portal.ERP5Site_isSupportRequestCreationClosed():\n
# Stop ticket creation\n
return\n
\n
date_check_limit = addToDate(DateTime(), to_add={\'hour\': -1})\n
\n
if (date_check_limit - hosting_subscription.getCreationDate()) < 0:\n
# Too early to check\n
return\n
\n
#if not source_instance:\n
# return\n
\n
software_instance_list = hosting_subscription.getSpecialiseRelatedValueList(\n
portal_type=["Software Instance", "Slave Instance"])\n
\n
has_newest_allocated_instance = False\n
has_unallocated_instance = False\n
failing_instance = None\n
\n
# Check if at least one software Instance is Allocated\n
for instance in software_instance_list:\n
if instance.getSlapState() not in ["start_requested", "stop_requested"]:\n
continue\n
\n
if (date_check_limit - instance.getCreationDate()) < 0:\n
continue\n
\n
if instance.getAggregateValue() is not None:\n
has_newest_allocated_instance = True\n
if instance.getPortalType() == "Software Instance" and \\\n
instance.SoftwareInstance_hasReportedError():\n
return context.HostingSubscription_createSupportRequestEvent(\n
instance, \'slapos-crm-hosting-subscription-instance-state.notification\')\n
else:\n
has_unallocated_instance = True\n
failing_instance = instance\n
\n
if has_unallocated_instance and has_newest_allocated_instance:\n
return context.HostingSubscription_createSupportRequestEvent(\n
failing_instance, \'slapos-crm-hosting-subscription-instance-allocation.notification\')\n
\n
return\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
portal = context.getPortalObject()
ticket_title = "Hosting Subscription %s is failing." % context.getTitle()
description = "%s contains software instances which are unallocated or reporting errors." % (
context.getTitle())
support_request = context.Base_generateSupportRequestForSlapOS(
ticket_title,
description,
context.getRelativeUrl())
if support_request is None:
return
person = context.getDestinationSectionValue(portal_type="Person")
if not person:
return
if support_request.getSimulationState() != "validated":
support_request.validate()
# Send Notification message
message = description
notification_reference = notification_message_reference
notification_message = portal.portal_notifications.getDocumentValue(
reference=notification_reference)
if notification_message is not None:
mapping_dict = {'hosting_subscription_title':context.getTitle(),
'instance': instance.getTitle()}
message = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':mapping_dict})
return support_request.SupportRequest_trySendNotificationMessage(
ticket_title, message, person.getRelativeUrl())
......@@ -48,47 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
ticket_title = "Hosting Subscription %s is failing." % context.getTitle()\n
\n
description = "%s contains software instances which are unallocated or reporting errors." % (\n
context.getTitle())\n
\n
support_request = context.Base_generateSupportRequestForSlapOS(\n
ticket_title,\n
description,\n
context.getRelativeUrl())\n
\n
if support_request is None:\n
return\n
\n
person = context.getDestinationSectionValue(portal_type="Person")\n
if not person:\n
return\n
\n
if support_request.getSimulationState() != "validated":\n
support_request.validate()\n
\n
# Send Notification message\n
message = description\n
\n
notification_reference = notification_message_reference\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=notification_reference)\n
if notification_message is not None:\n
mapping_dict = {\'hosting_subscription_title\':context.getTitle(),\n
\'instance\': instance.getTitle()}\n
\n
message = notification_message.asText(\n
substitution_method_parameter_dict={\'mapping_dict\':mapping_dict})\n
\n
return support_request.SupportRequest_trySendNotificationMessage(\n
ticket_title, message, person.getRelativeUrl())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>instance, notification_message_reference</string> </value>
......
if 'service_provider' in context.getRoleList():
return True
for assignment in context.contentValues(portal_type="Assignment"):
if assignment.getValidationState() == "open" and \
assignment.getRole() == 'service_provider':
return True
return False
......@@ -48,19 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if \'service_provider\' in context.getRoleList():\n
return True\n
\n
for assignment in context.contentValues(portal_type="Assignment"):\n
if assignment.getValidationState() == "open" and \\\n
assignment.getRole() == \'service_provider\':\n
return True\n
\n
return False\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
from DateTime import DateTime
import json
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
try:
d = memcached_dict[context.getReference()]
except KeyError:
# Information not available
return None
d = json.loads(d)
result = d['text']
last_contact = DateTime(d.get('created_at'))
# Optimise by checking memcache information first.
if result.startswith('#error '):
return last_contact
return None
......@@ -48,32 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
import json\n
\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
\n
try:\n
d = memcached_dict[context.getReference()]\n
except KeyError:\n
# Information not available\n
return None\n
\n
d = json.loads(d)\n
result = d[\'text\']\n
last_contact = DateTime(d.get(\'created_at\'))\n
\n
# Optimise by checking memcache information first.\n
if result.startswith(\'#error \'):\n
return last_contact\n
\n
return None\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
from DateTime import DateTime
import json
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
if context.getAggregateValue(portal_type="Computer Partition") is not None:
try:
d = memcached_dict[context.getReference()]
except KeyError:
return
d = json.loads(d)
result = d['text']
last_contact = DateTime(d.get('created_at'))
# Optimise by checking memcache information first.
if result.startswith('#error '):
return last_contact
# XXX time limit of 48 hours for run at least once.
return None
......@@ -48,34 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
import json\n
\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
\n
if context.getAggregateValue(portal_type="Computer Partition") is not None:\n
try:\n
d = memcached_dict[context.getReference()]\n
except KeyError:\n
return \n
\n
d = json.loads(d)\n
result = d[\'text\']\n
last_contact = DateTime(d.get(\'created_at\'))\n
\n
# Optimise by checking memcache information first.\n
if result.startswith(\'#error \'):\n
return last_contact\n
\n
# XXX time limit of 48 hours for run at least once.\n
\n
return None\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
support_request = context
portal = context.getPortalObject()
resource = portal.service_module.slapos_crm_information.getRelativeUrl()
# create Web message if needed for this ticket
last_event = context.portal_catalog.getResultValue(
title=message_title,
follow_up_uid=support_request.getUid(),
sort_on=[('delivery.start_date', 'DESC')],
)
if last_event:
# User has already been notified for this problem.
return last_event
event = portal.event_module.slapos_crm_web_message_template.\
Base_createCloneDocument(batch_mode=1)
event.edit(
title=message_title,
text_content=message,
start_date = DateTime(),
resource = resource,
source=source_relative_url,
follow_up=support_request.getRelativeUrl(),
)
event.stop()
event.deliver()
event.immediateReindexObject()
return event
......@@ -48,41 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>support_request = context\n
portal = context.getPortalObject()\n
\n
resource = portal.service_module.slapos_crm_information.getRelativeUrl()\n
# create Web message if needed for this ticket\n
last_event = context.portal_catalog.getResultValue(\n
title=message_title,\n
follow_up_uid=support_request.getUid(), \n
sort_on=[(\'delivery.start_date\', \'DESC\')],\n
)\n
if last_event:\n
# User has already been notified for this problem.\n
return last_event\n
\n
event = portal.event_module.slapos_crm_web_message_template.\\\n
Base_createCloneDocument(batch_mode=1)\n
\n
event.edit(\n
title=message_title,\n
text_content=message,\n
start_date = DateTime(),\n
resource = resource,\n
source=source_relative_url,\n
follow_up=support_request.getRelativeUrl(),\n
)\n
event.stop()\n
event.deliver()\n
\n
event.immediateReindexObject()\n
\n
return event\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>message_title, message, source_relative_url</string> </value>
......
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