Commit 583f197d authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_free_subscription_request: initial commit

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