Commit fff656be authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_free_subscription_request: initial commit

parent c8f9394b
......@@ -51,38 +51,48 @@
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
if portal.Base_getHMACHexdigest(portal.Base_getEventHMACKey(), event_id) != hmac:\n
from zExceptions import Unauthorized\n
raise Unauthorized\n
\n
event = portal.event_module[event_id]\n
\n
# First create a request\n
request = portal.free_subscription_request_module.newContent(\n
source=event.getSource(),\n
destination=event.getDestination(),\n
resource = event.getResource(),\n
free_subscription_request_type="unsubscription",\n
causality_value=event,\n
)\n
if subscription_type == "unsubscription":\n
if portal.Base_getHMACHexdigest(portal.Base_getEventHMACKey(), event_id) != hmac:\n
from zExceptions import Unauthorized\n
raise Unauthorized\n
\n
event = portal.event_module[event_id]\n
\n
# First create a request\n
request = portal.free_subscription_request_module.newContent(\n
source=event.getSource(),\n
destination=event.getDestination(),\n
resource = event.getResource(),\n
free_subscription_request_type="unsubscription",\n
causality_value=event,\n
)\n
\n
free_subscription_list = portal.portal_catalog(portal_type="Free Subscription",\n
default_resource_uid=event.getResourceUid(),\n
default_source_uid=event.getSourceUid(),\n
default_destination_uid=event.getDestinationUid())\n
\n
free_subscription_list = portal.portal_catalog(portal_type="Free Subscription",\n
default_resource_uid=event.getResourceUid(),\n
default_source_uid=event.getSourceUid(),\n
default_destination_uid=event.getDestinationUid())\n
if len(free_subscription_list) != 1:\n
raise ValueError("Impossible to find the free subscription (%d)" %\n
(len(free_subscription_list)))\n
free_subscription = free_subscription_list[0].getObject()\n
request.setFollowUpValue(free_subscription)\n
\n
if len(free_subscription_list) != 1:\n
raise ValueError("Impossible to find the free subscription (%d)" %\n
(len(free_subscription_list)))\n
free_subscription = free_subscription_list[0].getObject()\n
request.setFollowUpValue(free_subscription)\n
else:\n
request = portal.free_subscription_request_module.newContent(\n
source=source,\n
destination=destination,\n
resource=resource,\n
free_subscription_request_type="subscription",\n
causality=causality,\n
)\n
\n
request.submit()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>event_id, hmac</string> </value>
<value> <string>causality=None, resource=None, destination=None, source=None, event_id=None, hmac=None, subscription_type="unsubscription"</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -57,6 +57,7 @@ free_subscription = context.getPortalObject().free_subscription_module.newConten
source=source,\n
resource=resource,\n
effective_date=start_date,\n
start_date=start_date,\n
title=title)\n
\n
free_subscription.validate()\n
......
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