From: sunew <svn...@pl...> - 2006-12-17 17:16:13
|
Author: sunew Date: Sun Dec 17 17:16:05 2006 New Revision: 34793 Added: PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.cpy - copied, changed from r34790, PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.py PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.cpy.metadata (contents, props changed) Removed: PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.py Modified: PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_update.cpy PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_view.cpt Log: Remember the return url across updates and deletes. Copied: PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.cpy (from r34790, PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.py) ============================================================================== --- PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.py (original) +++ PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.cpy Sun Dec 17 17:16:05 2006 @@ -1,8 +1,9 @@ -## Script (Python) "cart_delete" +## Controller Python Script "cart_delete" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script +##bind state=state ##bind subpath=traverse_subpath ##parameters=cart_item=[] ##title=Delete items from the cart @@ -16,7 +17,12 @@ cart.delItem(cart_item) plone_utils.addPortalMessage(_(u'Cart item(s) deleted.')) +# remember mall_came_from +state.set(mall_came_from = context.REQUEST.get('mall_came_from', '')) + if pcm.getAdd_to_cart_mode() == 'stay' and not context.REQUEST.has_key('cart_view'): - return context.REQUEST.RESPONSE.redirect('%s/view' % (context.absolute_url())) + state.setStatus('view') + else: - return context.REQUEST.RESPONSE.redirect('%s/cart_view' % (context.portal_url())) + state.setStatus('success') +return state Added: PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.cpy.metadata ============================================================================== --- (empty file) +++ PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_delete.cpy.metadata Sun Dec 17 17:16:05 2006 @@ -0,0 +1,7 @@ +[validators] +validators= + +[actions] +action.failure=traverse_to:string:${portal_url}/cart_view +action.success=redirect_to:string:${portal_url}/cart_view +action.view=redirect_to:string:view Modified: PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_update.cpy ============================================================================== --- PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_update.cpy (original) +++ PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_update.cpy Sun Dec 17 17:16:05 2006 @@ -26,6 +26,9 @@ plone_utils.addPortalMessage(_(u'Cart updated.')) +# remember mall_came_from +state.set(mall_came_from = context.REQUEST.get('mall_came_from', '')) + # Where to go next? if state.getButton() == 'checkout': state.setStatus('checkout') Modified: PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_view.cpt ============================================================================== --- PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_view.cpt (original) +++ PloneMall/core/PloneMallCart/branches/1.1/PloneMallCart/skins/PloneMallCart/cart_view.cpt Sun Dec 17 17:16:05 2006 @@ -23,76 +23,79 @@ <form tal:define="errors options/state/getErrors" tal:attributes="action string:${here/absolute_url}/${template/id};" - method="post" - tal:condition="cart_item"> + method="post"> <input type="hidden" name="cart_view" value="1" /> <input type="hidden" name="form.submitted" value="1" /> <input type="hidden" name="mall_came_from" value="" tal:attributes="value mall_came_from" /> - <p tal:define="err errors/foo|nothing" tal:condition="err" tal:content="err" /> - - <table class="listing" - cellpadding="0" - cellspacing="0"> - <thead> - <tr> - <th i18n:translate="cart_header_title">Product</th> - <th i18n:translate="cart_header_description">Description</th> - <th i18n:translate="cart_header_quantity">Quantity</th> - <th i18n:translate="cart_header_price">Price</th> - <th i18n:translate="cart_header_total">Total</th> - <th i18n:translate="cart_header_delete">Delete</th> - </tr> - </thead> - <tbody> - <metal:block tal:repeat="item cart_item"> - <tr class="even" - tal:define="oddrow repeat/item/odd; - product item/getMallItem" - tal:attributes="class python:test(oddrow, 'even', 'odd')" > - <td> - <a tal:attributes="href product/absolute_url" - tal:content="product/Title"> - cart item - </a> - </td> - <td tal:content="product/Description"></td> - <td><input type="text" size="5" - tal:attributes="value item/getQuantity; - name string:quantity_${item/getId}; - tabindex tabindex/next" /></td> - <td tal:content="item/getPrice"></td> - <td tal:content="item/getTotal"></td> - <td><input type="checkbox" - name="cart_item:list" - class="noborder" - tal:attributes="value item/getId; - tabindex tabindex/next" /></td> - </tr> - </metal:block> - </tbody> - </table> - <div><p>Total: <b tal:content="cart/getTotal">US$ 100.00</b></p></div> + <tal:not_empty tal:condition="cart_item"> + <p tal:define="err errors/foo|nothing" tal:condition="err" tal:content="err" /> + + <table class="listing" + cellpadding="0" + cellspacing="0"> + <thead> + <tr> + <th i18n:translate="cart_header_title">Product</th> + <th i18n:translate="cart_header_description">Description</th> + <th i18n:translate="cart_header_quantity">Quantity</th> + <th i18n:translate="cart_header_price">Price</th> + <th i18n:translate="cart_header_total">Total</th> + <th i18n:translate="cart_header_delete">Delete</th> + </tr> + </thead> + <tbody> + <metal:block tal:repeat="item cart_item"> + <tr class="even" + tal:define="oddrow repeat/item/odd; + product item/getMallItem" + tal:attributes="class python:test(oddrow, 'even', 'odd')" > + <td> + <a tal:attributes="href product/absolute_url" + tal:content="product/Title"> + cart item + </a> + </td> + <td tal:content="product/Description"></td> + <td><input type="text" size="5" + tal:attributes="value item/getQuantity; + name string:quantity_${item/getId}; + tabindex tabindex/next" /></td> + <td tal:content="item/getPrice"></td> + <td tal:content="item/getTotal"></td> + <td><input type="checkbox" + name="cart_item:list" + class="noborder" + tal:attributes="value item/getId; + tabindex tabindex/next" /></td> + </tr> + </metal:block> + </tbody> + </table> + <div><p>Total: <b tal:content="cart/getTotal">US$ 100.00</b></p></div> + </tal:not_empty> <div> - <input class="context" - type="submit" - value="Update" - name="form.button.cart_update" - i18n:attributes="value" - tal:attributes="tabindex tabindex/next" /> - <input class="context" - type="submit" - value="Delete" - name="form.button.cart_delete" - i18n:attributes="value" - tal:attributes="tabindex tabindex/next" /> - <input class="context" - type="submit" - value="Checkout" - name="form.button.checkout" - i18n:attributes="value" - tal:attributes="tabindex tabindex/next" /> + <tal:not_empty tal:condition="cart_item"> + <input class="context" + type="submit" + value="Update" + name="form.button.cart_update" + i18n:attributes="value" + tal:attributes="tabindex tabindex/next" /> + <input class="context" + type="submit" + value="Delete" + name="form.button.cart_delete" + i18n:attributes="value" + tal:attributes="tabindex tabindex/next" /> + <input class="context" + type="submit" + value="Checkout" + name="form.button.checkout" + i18n:attributes="value" + tal:attributes="tabindex tabindex/next" /> + </tal:not_empty> <input class="context" type="submit" value="Return" |