Commits

Josh VanderLinden committed 9368516

#119 - An attempt to maintain order information instead of losing orders

  • Participants
  • Parent commits 406849d

Comments (0)

Files changed (1)

 diff --git a/satchmo/apps/satchmo_store/shop/models.py b/satchmo/apps/satchmo_store/shop/models.py
 --- a/satchmo/apps/satchmo_store/shop/models.py
 +++ b/satchmo/apps/satchmo_store/shop/models.py
-@@ -583,6 +583,9 @@
+@@ -570,6 +570,7 @@
+     ('Shipped', _('Shipped')),
+     ('Complete', _('Complete')),
+     ('Cancelled', _('Cancelled')),
++    ('Deleted', _('** Deleted **')),
+ )
+ 
+ class OrderManager(models.Manager):
+@@ -583,6 +584,9 @@
          if 'orderID' in request.session:
              try:
                  order = Order.objects.get(id=request.session['orderID'])
                  # TODO: Validate against logged-in user.
              except Order.DoesNotExist:
                  pass
-@@ -656,6 +659,7 @@
+@@ -599,13 +603,16 @@
+         """Delete cart from request if it exists and is incomplete (has no status)"""
+         try:
+             order = Order.objects.from_request(request)
+-            if not order.status:
+-                del request.session['orderID']
+-                log.info("Deleting incomplete order #%i from database", order.id)
+-                order.delete()
+-                return True
+         except Order.DoesNotExist:
+             pass
++        else:
++            if not order.status:
++                #del request.session['orderID']
++                log.info("Deleting incomplete order #%i from database", order.id)
++                order.status = 'Deleted'
++                order.save()
++                return True
++
+         return False
+ 
+ class Order(models.Model):
+@@ -656,6 +663,7 @@
      time_stamp = models.DateTimeField(_("Timestamp"), blank=True, null=True)
      status = models.CharField(_("Status"), max_length=20, choices=ORDER_STATUS,
          blank=True, help_text=_("This is set automatically."))