Bruce Kroeze avatar Bruce Kroeze committed 707886e Merge

updating from upstream

Comments (0)

Files changed (4)


 - Improve handling of the MEDIA_ROOT on Windows systems
 - Add a documentation section about customizing the admin - :doc:`custom-admin`
 - Handle error if unicode value is entered in the cart quantity field
+- Add a persistent cart capability for previously logged in users
+- Django 1.2 compatibility change in save signatures
+- Remove some dupe code in the login functions
+- Turn off autocomplete on cc#'s and ccvs in the checkout form 
+- Move the import of trml2pdf so that startup is quicker
+- Fix a bug in the category slug url


 from satchmo_store.accounts import signals
 from import CUSTOMER_ID
 from import Contact
-from import Config
+from import Config, Cart
 import logging
 log = logging.getLogger('satchmo_store.accounts.views')
             login(request, form.get_user())
             if request.session.test_cookie_worked():
+                if config_value('SHOP','PERSISTENT_CART'):
+                    _get_prev_cart(request)
             return (True, HttpResponseRedirect(redirect_to))
     return (False, form)
+def _get_prev_cart(request):
+    try:
+        contact = request.user.contact_set.get()
+        saved_cart = contact.cart_set.latest('date_time_created')
+        # If the latest cart has len == 0, cart is unusable.
+        if len(saved_cart) and request.session['cart']:
+            # Merge the two carts together
+            existing_cart = Cart.objects.from_request(request, create=False)
+            saved_cart.merge_carts(existing_cart)
+            request.session['cart'] =
+    except Exception, e:
+        pass
 def register_handle_address_form(request, redirect=None):
     Handle all registration logic.  This is broken out from "register" to allow easy overriding/hooks


         default = 0
+PERSISTENT_CART = config_register(
+    BooleanValue(SHOP_GROUP,
+    description = _('Persistent Cart?'),
+    help_text = _("When a user logs in, attempt to retrieve previous carts and merge with existing?"),
+    default = False
+    ))
 #### Google Group ####


+    def merge_carts(self, src_cart):
+        """
+        Merge the items from the src_cart into
+        the destination. Source cart will be emptied
+        """
+        for item in src_cart.cartitem_set.all():
+            self.add_item(item.product, item.quantity, item.details.all())
+            item.delete()
     def empty(self):
         for item in self.cartitem_set.all():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.