浏览代码

Acually fixed the bug this time.

master
David Winterbottom 13 年前
父节点
当前提交
b9256b0813
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. 3
    3
      oscar/apps/catalogue/abstract_models.py
  2. 6
    1
      oscar/apps/catalogue/tests.py

+ 3
- 3
oscar/apps/catalogue/abstract_models.py 查看文件

@@ -331,7 +331,7 @@ class AbstractProduct(models.Model):
331 331
 
332 332
 
333 333
 class ProductRecommendation(models.Model):
334
-    u"""
334
+    """
335 335
     'Through' model for product recommendations
336 336
     """
337 337
     primary = models.ForeignKey('catalogue.Product', related_name='primary_recommendations')
@@ -380,7 +380,7 @@ class ProductAttributesContainer(object):
380 380
                                              'err': e})
381 381
         
382 382
     def get_values(self):
383
-        return self.product.productattributevalue_set.all()
383
+        return self.product.attribute_values.all()
384 384
     
385 385
     def get_value_by_attribute(self, attribute):
386 386
         return self.get_values().get(attribute=attribute)    
@@ -494,7 +494,7 @@ class AbstractProductAttribute(models.Model):
494 494
         
495 495
     def save_value(self, product, value):
496 496
         try:
497
-            value_obj = product.productattributevalue_set.get(attribute=self)
497
+            value_obj = product.attribute_values.get(attribute=self)
498 498
         except get_model('catalogue', 'ProductAttributeValue').DoesNotExist:
499 499
             if value == None or value == '':
500 500
                 return

+ 6
- 1
oscar/apps/catalogue/tests.py 查看文件

@@ -3,7 +3,8 @@ from django.core.exceptions import ValidationError
3 3
 from django.core.urlresolvers import reverse
4 4
 from django.conf import settings
5 5
 
6
-from oscar.apps.catalogue.models import Product, ProductClass, Category
6
+from oscar.apps.catalogue.models import Product, ProductClass, Category, \
7
+        ProductAttribute
7 8
 from oscar.apps.catalogue.categories import create_from_breadcrumbs
8 9
 
9 10
 
@@ -59,6 +60,10 @@ class ProductCreationTests(ProductTests):
59 60
 
60 61
     def setUp(self):
61 62
         super(ProductCreationTests, self).setUp()
63
+        ProductAttribute.objects.create(product_class=self.product_class,
64
+                                        name='Number of pages',
65
+                                        code='num_pages',
66
+                                        type='integer')
62 67
         Product.ENABLE_ATTRIBUTE_BINDING = True
63 68
 
64 69
     def tearDown(self):

正在加载...
取消
保存