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