Commits

Josh VanderLinden committed 885afda

Automatic deploy

Comments (0)

Files changed (1)

 copy to satchmo/apps/shipping/modules/dv_flat/shipper.py
 --- a/satchmo/apps/shipping/modules/flat/shipper.py
 +++ b/satchmo/apps/shipping/modules/dv_flat/shipper.py
-@@ -1,48 +1,70 @@
+@@ -1,48 +1,81 @@
 -"""
 -Each shipping option uses the data in an Order object to calculate the shipping cost and return the value
 -"""
++import logging
++
  from decimal import Decimal
 -from django.utils.translation import ugettext, ugettext_lazy
 +from django.utils.translation import ugettext, ugettext_lazy as _
 -_ = ugettext_lazy
  from shipping.modules.base import BaseShipper
  
++log = logging.getLogger('shipping.modules.dv_flat')
++
  class Shipper(BaseShipper):
 -    id = "FlatRate"
 +    id = "DVPFlatRate"
 +    def group(self):
 +        """Returns the appropriate group for this order"""
 +
++        log.debug('Getting group')
 +        if self.is_international():
 +            return 'INTL_SHIPPING'
 +        return 'DOM_SHIPPING'
 +    def is_international(self):
 +        """Returns True if this order appears to be international"""
 +
++        log.debug('Checking international status')
 +        return self.contact and self.contact.shipping_address and \
 +            self.contact.shipping_address.country.iso2_code != 'US'
  
          """
 -        return "Flat Rate: %s" % config_value('SHIPPING', 'FLAT_RATE')
 +
++        log.debug('Stringifying module')
 +        return '%s: %s' % (
 +            self.description.replace(' Shipping', ''),
 +            config_value(self.group, 'FLAT_RATE')
          """
 -        return _("Flat Rate Shipping")
 +
++        log.debug('Getting module description')
 +        if self.is_international():
 +            return _('International Flat Rate Shipping')
 +
          """
          assert(self._calculated)
 +
++        log.debug('Returning cost')
          for cartitem in self.cart.cartitem_set.all():
              if cartitem.product.is_shippable:
 -                return config_value('SHIPPING', 'FLAT_RATE')
 +                return config_value(self.group, 'FLAT_RATE')
 +
++
++        log.debug('Order is not shippable')
          return Decimal("0.00")
  
      def method(self):
  
      def valid(self, order=None):
          """
-@@ -50,5 +72,6 @@
+@@ -50,5 +83,6 @@
          For example, may check to see if the recipient is in an allowed country
          or location.
          """