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

erp5_free_subscription_request: initial commit

parent 5ddd5fb6
...@@ -51,14 +51,15 @@ ...@@ -51,14 +51,15 @@
<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
if portal.Base_getHMACHexdigest(portal.Base_getEventHMACKey(), event_id) != hmac:\n
from zExceptions import Unauthorized\n from zExceptions import Unauthorized\n
raise Unauthorized\n raise Unauthorized\n
\n \n
event = portal.event_module[event_id]\n event = portal.event_module[event_id]\n
\n \n
# First create a request\n # First create a request\n
request = portal.free_subscription_request_module.newContent(\n request = portal.free_subscription_request_module.newContent(\n
source=event.getSource(),\n source=event.getSource(),\n
destination=event.getDestination(),\n destination=event.getDestination(),\n
resource = event.getResource(),\n resource = event.getResource(),\n
...@@ -66,23 +67,32 @@ request = portal.free_subscription_request_module.newContent(\n ...@@ -66,23 +67,32 @@ request = portal.free_subscription_request_module.newContent(\n
causality_value=event,\n causality_value=event,\n
)\n )\n
\n \n
free_subscription_list = portal.portal_catalog(portal_type="Free Subscription",\n free_subscription_list = portal.portal_catalog(portal_type="Free Subscription",\n
default_resource_uid=event.getResourceUid(),\n default_resource_uid=event.getResourceUid(),\n
default_source_uid=event.getSourceUid(),\n default_source_uid=event.getSourceUid(),\n
default_destination_uid=event.getDestinationUid())\n default_destination_uid=event.getDestinationUid())\n
\n \n
if len(free_subscription_list) != 1:\n if len(free_subscription_list) != 1:\n
raise ValueError("Impossible to find the free subscription (%d)" %\n raise ValueError("Impossible to find the free subscription (%d)" %\n
(len(free_subscription_list)))\n (len(free_subscription_list)))\n
free_subscription = free_subscription_list[0].getObject()\n free_subscription = free_subscription_list[0].getObject()\n
request.setFollowUpValue(free_subscription)\n request.setFollowUpValue(free_subscription)\n
\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 \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