Changeset 1004
- Timestamp:
- 01/16/08 04:46:10 (1 year ago)
- Files:
-
- satchmo/trunk/satchmo/product/models.py (modified) (7 diffs)
- satchmo/trunk/satchmo/shipping/config.py (modified) (1 diff)
- satchmo/trunk/satchmo/shipping/modules/ups (added)
- satchmo/trunk/satchmo/shipping/modules/ups/__init__.py (added)
- satchmo/trunk/satchmo/shipping/modules/ups/config.py (added)
- satchmo/trunk/satchmo/shipping/modules/ups/shipper.py (added)
- satchmo/trunk/satchmo/shop/config.py (modified) (1 diff)
- satchmo/trunk/satchmo/templates/shipping (added)
- satchmo/trunk/satchmo/templates/shipping/ups (added)
- satchmo/trunk/satchmo/templates/shipping/ups/request.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
satchmo/trunk/satchmo/product/models.py
r991 r1004 20 20 from sets import Set 21 21 import logging 22 from django.core.validators import RequiredIfOtherFieldGiven 22 23 try: 23 24 from django.utils.safestring import mark_safe … … 41 42 def protected_dir(): 42 43 return normalize_dir(config_value('PRODUCT', 'PROTECTED_DIR')) 44 45 def dimension_units(): 46 if config_value('SHOP','MEASUREMENT_SYSTEM')[0] == 'metric': 47 return ([('cm','cm')]) 48 else: 49 return ([('in','in')]) 50 51 def weight_units(): 52 if config_value('SHOP','MEASUREMENT_SYSTEM')[0] == 'metric': 53 return ([('kg','kg')]) 54 else: 55 return ([('lb','lb')]) 56 57 length_validator = RequiredIfOtherFieldGiven('length', _("A unit of measure must be entered for the length")) 58 width_validator = RequiredIfOtherFieldGiven('width', _("A unit of measure must be entered for the width")) 59 height_validator = RequiredIfOtherFieldGiven('height', _("A unit of measure must be entered for the height")) 60 weight_validator = RequiredIfOtherFieldGiven('weight', _("A unit of measure must be entered for the weight")) 43 61 44 62 class Category(models.Model): … … 371 389 name = models.CharField(_("Full Name"), max_length=255, help_text=_("This is what the product will be called in the default site language. To add non-default translations, use the Product Translation section below.")) 372 390 slug = models.SlugField(_("Slug Name"), unique=True, prepopulate_from=('name',), core=True, blank=False) 373 sku = models.CharField(_("SKU"), max_length=255, blank=True, null=True, unique=True )391 sku = models.CharField(_("SKU"), max_length=255, blank=True, null=True, unique=True, help_text=_("Defaults to slug if left blank")) 374 392 short_description = models.TextField(_("Short description of product"), help_text=_("This should be a 1 or 2 line description in the default site language for use in product listing screens"), max_length=200, default='', blank=True) 375 393 description = models.TextField(_("Description of product"), help_text=_("This field can contain HTML and should be a few paragraphs in the default site language explaining the background of the product, and anything that would help the potential customer make their purchase."), default='', blank=True) … … 382 400 ordering = models.IntegerField(_("Ordering"), default=0, help_text=_("Override alphabetical order in category display")) 383 401 weight = models.DecimalField(_("Weight"), max_digits=8, decimal_places=2, null=True, blank=True) 402 weight_units = models.CharField(_("Weight units"), max_length=3, choices=weight_units(), null=True, blank=True, validator_list=[weight_validator]) 384 403 length = models.DecimalField(_("Length"), max_digits=6, decimal_places=2, null=True, blank=True) 404 length_units = models.CharField(_("Length units"), max_length=3, choices=dimension_units(), null=True, blank=True, validator_list=[length_validator]) 385 405 width = models.DecimalField(_("Width"), max_digits=6, decimal_places=2, null=True, blank=True) 406 width_units = models.CharField(_("Width units"), max_length=3, choices=dimension_units(), null=True, blank=True, validator_list=[width_validator]) 386 407 height = models.DecimalField(_("Height"), max_digits=6, decimal_places=2, null=True, blank=True) 408 height_units = models.CharField(_("Height units"), max_length=3, choices=dimension_units(), null=True, blank=True, validator_list=[height_validator]) 387 409 related_items = models.ManyToManyField('self', blank=True, null=True, verbose_name=_('Related Items'), related_name='related_products') 388 410 also_purchased = models.ManyToManyField('self', blank=True, null=True, verbose_name=_('Previously Purchased'), related_name='also_products') … … 495 517 else: 496 518 return False; 519 520 def _has_full_dimensions(self): 521 """Return true if the dimensions all have units and values. Used in shipping calcs. """ 522 if self.length and self.length_units and self.width and self.width_units and self.height and self.height_units: 523 return True 524 return False 525 has_full_dimensions = property(_has_full_dimensions) 526 527 def _has_full_weight(self): 528 """Return True if we have weight and weight units""" 529 if self.weight and self.weight_units: 530 return True 531 return False 532 has_full_weight = property(_has_full_weight) 497 533 498 534 def __unicode__(self): … … 509 545 (None, {'fields': ('category', 'name', 'slug', 'sku', 'description', 'short_description', 'date_added', 'active', 'featured', 'items_in_stock','ordering')}), 510 546 (_('Meta Data'), {'fields': ('meta',), 'classes': 'collapse'}), 511 (_('Item Dimensions'), {'fields': (('length', ' width','height',),'weight'), 'classes': 'collapse'}),547 (_('Item Dimensions'), {'fields': (('length', 'length_units','width','width_units','height','height_units'),('weight','weight_units')), 'classes': 'collapse'}), 512 548 (_('Tax'), {'fields':('taxable', 'taxClass'), 'classes': 'collapse'}), 513 549 (_('Related Products'), {'fields':('related_items','also_purchased'),'classes':'collapse'}), … … 523 559 if not self.id: 524 560 self.date_added = datetime.date.today() 525 561 if not self.sku: 562 self.sku = self.slug 526 563 super(Product, self).save() 527 564 satchmo/trunk/satchmo/shipping/config.py
r941 r1004 20 20 # just add satchmo.shipping.modules.tiered to your INSTALLED_APPS, you don't 21 21 # need to add it to CUSTOM_SHIPPING_MODULES either. 22 _default_modules = ('dummy', 'flat', 'per' )22 _default_modules = ('dummy', 'flat', 'per', 'ups') 23 23 24 24 for module in _default_modules: 25 try:26 load_module("satchmo.shipping.modules.%s.config" % module)27 except ImportError:28 log.debug('Could not load default shipping module configuration: %s', module)25 #try: 26 load_module("satchmo.shipping.modules.%s.config" % module) 27 #except ImportError: 28 # log.debug('Could not load default shipping module configuration: %s', module) 29 29 30 30 # --- Load any extra shipping modules. --- satchmo/trunk/satchmo/shop/config.py
r955 r1004 28 28 description= _("Number of featured items to display"), 29 29 default=20)) 30 30 31 MEASUREMENT_SYSTEM = config_register( 32 MultipleStringValue(SHOP_GROUP, 33 'MEASUREMENT_SYSTEM', 34 description = _("Measurement system to use in store"), 35 choices = [('metric',_('Metric')), 36 ('imperial',_('Imperial'))], 37 default = "imperial")) 31 38 #### Google Group #### 32 39
