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

Use selection to store user choices

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42519 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5c6a2418
...@@ -58,7 +58,9 @@ if len(uids) != 1:\n ...@@ -58,7 +58,9 @@ if len(uids) != 1:\n
keep_items={\'portal_status_message\':context.Base_translateString("Please select one service.")})\n keep_items={\'portal_status_message\':context.Base_translateString("Please select one service.")})\n
else:\n else:\n
session = context.WebSection_getVifibSession()\n session = context.WebSection_getVifibSession()\n
session[\'instance_software_product_uid\'] = uids[0]\n params = portal.portal_selections.getSelectionParamsFor(\'vifib_session_id\')\n
params["instance_software_product_uid"] = uids[0]\n
portal.portal_selections.setSelectionParamsFor(\'vifib_session_id\', params)\n
\n \n
if kw.has_key(\'came_from\'):\n if kw.has_key(\'came_from\'):\n
#we override the context to redirect the user to the next web section\n #we override the context to redirect the user to the next web section\n
...@@ -110,6 +112,7 @@ context.WebSection_viewNextStep()\n ...@@ -110,6 +112,7 @@ context.WebSection_viewNextStep()\n
<string>portal</string> <string>portal</string>
<string>len</string> <string>len</string>
<string>session</string> <string>session</string>
<string>params</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>_write_</string> <string>_write_</string>
</tuple> </tuple>
......
...@@ -51,8 +51,10 @@ ...@@ -51,8 +51,10 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""Get the release of the selected product"""\n <value> <string>"""Get the release of the selected product"""\n
portal = context.getPortalObject()\n
session = context.WebSection_getVifibSession()\n session = context.WebSection_getVifibSession()\n
uid = session.get(\'instance_software_product_uid\', None)\n params = portal.portal_selections.getSelectionParamsFor(\'vifib_session_id\')\n
uid = params[\'instance_software_product_uid\']\n
\n \n
# assert there is only one item\n # assert there is only one item\n
if uid is None:\n if uid is None:\n
...@@ -102,9 +104,12 @@ else:\n ...@@ -102,9 +104,12 @@ else:\n
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal</string>
<string>session</string> <string>session</string>
<string>None</string> <string>params</string>
<string>_getitem_</string>
<string>uid</string> <string>uid</string>
<string>None</string>
<string>AttributeError</string> <string>AttributeError</string>
</tuple> </tuple>
</value> </value>
......
...@@ -53,6 +53,12 @@ ...@@ -53,6 +53,12 @@
<value> <string>""" \n <value> <string>""" \n
Add resource to current (or to be created shopping cart). \n Add resource to current (or to be created shopping cart). \n
"""\n """\n
selection = context.getPortalObject().portal_selections.getSelectionFor(\'vifib_session_id\')\n
if selection is None:\n
context.getPortalObject().portal_selections.setSelectionParamsFor(\'vifib_session_id\', {})\n
selection = context.getPortalObject().portal_selections.getSelectionFor(\'vifib_session_id\')\n
return selection\n
\n
from DateTime import DateTime\n from DateTime import DateTime\n
from random import choice\n from random import choice\n
import string\n import string\n
...@@ -63,6 +69,7 @@ session_id = request.get(\'vifib_session_id\', None)\n ...@@ -63,6 +69,7 @@ session_id = request.get(\'vifib_session_id\', None)\n
portal_sessions = context.portal_sessions\n portal_sessions = context.portal_sessions\n
\n \n
if session_id is None:\n if session_id is None:\n
raise NotImplementedError, "no session..."\n
## first call so generate session_id and send back via cookie\n ## first call so generate session_id and send back via cookie\n
now = DateTime()\n now = DateTime()\n
session_id = \'\'.join([choice(string.letters) for i in range(20)])\n session_id = \'\'.join([choice(string.letters) for i in range(20)])\n
...@@ -105,17 +112,19 @@ return portal_sessions[session_id]\n ...@@ -105,17 +112,19 @@ return portal_sessions[session_id]\n
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>_getattr_</string>
<string>context</string>
<string>selection</string>
<string>None</string>
<string>DateTime</string> <string>DateTime</string>
<string>random</string> <string>random</string>
<string>choice</string> <string>choice</string>
<string>string</string> <string>string</string>
<string>_getattr_</string>
<string>context</string>
<string>request</string> <string>request</string>
<string>expire_timeout_days</string> <string>expire_timeout_days</string>
<string>None</string>
<string>session_id</string> <string>session_id</string>
<string>portal_sessions</string> <string>portal_sessions</string>
<string>NotImplementedError</string>
<string>now</string> <string>now</string>
<string>$list0</string> <string>$list0</string>
<string>_getiter_</string> <string>_getiter_</string>
......
...@@ -60,7 +60,8 @@ if context.getPortalType() != "Computer":\n ...@@ -60,7 +60,8 @@ if context.getPortalType() != "Computer":\n
raise NotImplementedError, "Should be called on a Computer"\n raise NotImplementedError, "Should be called on a Computer"\n
\n \n
session = context.WebSection_getVifibSession()\n session = context.WebSection_getVifibSession()\n
session[\'computer_uid\'] = context.getUid()\n portal.portal_selections.setSelectionParamsFor(\'vifib_session_id\', {\'computer_uid\': context.getUid()})\n
# session[\'computer_uid\'] = context.getUid()\n
\n \n
web_section = context.getWebSectionValue()\n web_section = context.getWebSectionValue()\n
return web_section.Base_redirect(\'install-a-software\', keep_items={\'editable_mode\': 0})\n return web_section.Base_redirect(\'install-a-software\', keep_items={\'editable_mode\': 0})\n
...@@ -112,7 +113,6 @@ return web_section.Base_redirect(\'install-a-software\', keep_items={\'editable_ ...@@ -112,7 +113,6 @@ return web_section.Base_redirect(\'install-a-software\', keep_items={\'editable_
<string>service</string> <string>service</string>
<string>NotImplementedError</string> <string>NotImplementedError</string>
<string>session</string> <string>session</string>
<string>_write_</string>
<string>web_section</string> <string>web_section</string>
</tuple> </tuple>
</value> </value>
......
...@@ -56,6 +56,7 @@ prefered_resource = portal.portal_preferences.getPreferredSoftwareSetupResource( ...@@ -56,6 +56,7 @@ prefered_resource = portal.portal_preferences.getPreferredSoftwareSetupResource(
service = portal.restrictedTraverse(prefered_resource)\n service = portal.restrictedTraverse(prefered_resource)\n
\n \n
session = context.WebSection_getVifibSession()\n session = context.WebSection_getVifibSession()\n
params = portal.portal_selections.getSelectionParamsFor(\'vifib_session_id\')\n
\n \n
##Get item list\n ##Get item list\n
item_list = []\n item_list = []\n
...@@ -70,7 +71,7 @@ item = item_list[0]\n ...@@ -70,7 +71,7 @@ item = item_list[0]\n
# XXX Check that release is associate to product\n # XXX Check that release is associate to product\n
\n \n
computer = portal.portal_catalog.getResultValue(\n computer = portal.portal_catalog.getResultValue(\n
uid=session[\'computer_uid\'],\n uid=params[\'computer_uid\'],\n
portal_type="Computer",\n portal_type="Computer",\n
)\n )\n
\n \n
...@@ -102,9 +103,12 @@ packing_list.newContent(\n ...@@ -102,9 +103,12 @@ packing_list.newContent(\n
portal.portal_workflow.doActionFor(packing_list, "confirm_action")\n portal.portal_workflow.doActionFor(packing_list, "confirm_action")\n
# packing_list.confirm()\n # packing_list.confirm()\n
\n \n
session[\'instance_software_product_uid\'] = ""\n # session[\'instance_software_product_uid\'] = ""\n
session[\'instance_software_release_uid\'] = ""\n # session[\'instance_software_release_uid\'] = ""\n
session[\'computer_uid\'] = ""\n # session[\'computer_uid\'] = ""\n
params[\'instance_software_product_uid\'] = None\n
params[\'instance_software_release_uid\'] = None\n
params[\'computer_uid\'] = None\n
\n \n
web_section = context.getWebSiteValue()\n web_section = context.getWebSiteValue()\n
return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n
...@@ -154,6 +158,7 @@ return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n ...@@ -154,6 +158,7 @@ return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n
<string>prefered_resource</string> <string>prefered_resource</string>
<string>service</string> <string>service</string>
<string>session</string> <string>session</string>
<string>params</string>
<string>item_list</string> <string>item_list</string>
<string>$list0</string> <string>$list0</string>
<string>_getiter_</string> <string>_getiter_</string>
...@@ -168,6 +173,7 @@ return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n ...@@ -168,6 +173,7 @@ return web_section.Base_redirect(keep_items={\'editable_mode\': 0})\n
<string>module</string> <string>module</string>
<string>DateTime</string> <string>DateTime</string>
<string>packing_list</string> <string>packing_list</string>
<string>None</string>
<string>_write_</string> <string>_write_</string>
<string>web_section</string> <string>web_section</string>
</tuple> </tuple>
......
266 267
\ No newline at end of file \ No newline at end of file
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