Преглед изворни кода

Drop OSCAR_OFFER_BLACKLIST_PRODUCT functionality

It only prevents adding a product to a range; offers can be applied
nonetheless (despite the docs saying otherwise). The same functionality
can be achieved by overriding get_is_discountable, so it can be safely
removed.
master
Maik Hoepfel пре 11 година
родитељ
комит
8a03abb0bb

+ 0
- 20
docs/source/ref/settings.rst Прегледај датотеку

@@ -312,26 +312,6 @@ used in Oscar's default templates but could be used to include static assets
312 312
 Offer settings
313 313
 ==============
314 314
 
315
-``OSCAR_OFFER_BLACKLIST_PRODUCT``
316
----------------------------------
317
-
318
-Default: ``None``
319
-
320
-A function which takes a product as its sole parameter and returns a boolean
321
-indicating if the product is blacklisted from offers or not.
322
-
323
-Example::
324
-
325
-    from decimal import Decimal as D
326
-
327
-    def is_expensive(product):
328
-        if product.has_stockrecord:
329
-            return product.stockrecord.price_incl_tax > D('1000.00')
330
-        return False
331
-
332
-    # Don't allow expensive products to be in offers
333
-    OSCAR_OFFER_BLACKLIST_PRODUCT = is_expensive
334
-
335 315
 ``OSCAR_OFFER_ROUNDING_FUNCTION``
336 316
 ---------------------------------
337 317
 

+ 6
- 0
docs/source/releases/v0.8.rst Прегледај датотеку

@@ -490,6 +490,12 @@ Misc
490 490
   and not running an English locale, you will need to migrate the existing
491 491
   data to the English values.
492 492
 
493
+* Support for the ``OSCAR_OFFER_BLACKLIST_PRODUCT`` setting has been removed.
494
+  It was only partially supported: it prevented products from being
495
+  added to a range, but offers could be applied to the products nonetheless.
496
+  To prevent an offer being applied to a product, use ``is_discountable`` or
497
+  override ``get_is_discountable`` on your product instances.
498
+
493 499
 .. _rewritten: https://github.com/tangentlabs/django-oscar/commit/d8b4dbfed17be90846ea4bc47b5f7b39ad944c24
494 500
 
495 501
 Basket line stockrecords

+ 0
- 7
oscar/apps/offer/models.py Прегледај датотеку

@@ -843,13 +843,6 @@ class Range(models.Model):
843 843
         """
844 844
         Check whether the passed product is part of this range
845 845
         """
846
-        # We look for shortcircuit checks first before
847
-        # the tests that require more database queries.
848
-
849
-        if settings.OSCAR_OFFER_BLACKLIST_PRODUCT and \
850
-                settings.OSCAR_OFFER_BLACKLIST_PRODUCT(product):
851
-            return False
852
-
853 846
         # Delegate to a proxy class if one is provided
854 847
         if self.proxy_class:
855 848
             return load_proxy(self.proxy_class)().contains_product(product)

+ 0
- 3
oscar/defaults.py Прегледај датотеку

@@ -70,9 +70,6 @@ OSCAR_EAGER_ALERTS = True
70 70
 OSCAR_SEND_REGISTRATION_EMAIL = True
71 71
 OSCAR_FROM_EMAIL = 'oscar@example.com'
72 72
 
73
-# Offers
74
-OSCAR_OFFER_BLACKLIST_PRODUCT = None
75
-
76 73
 # Slug handling
77 74
 OSCAR_SLUG_FUNCTION = 'oscar.core.utils.default_slugifier'
78 75
 OSCAR_SLUG_MAP = {}

+ 1
- 29
tests/integration/offer/range_tests.py Прегледај датотеку

@@ -1,37 +1,9 @@
1
-from django.conf import settings
2 1
 from django.test import TestCase
3 2
 
4 3
 from oscar.apps.offer import models
5 4
 from oscar.test.factories import create_product
6 5
 
7 6
 
8
-class TestWholeSiteRangeWithGlobalBlacklist(TestCase):
9
-
10
-    def setUp(self):
11
-        self.range = models.Range(
12
-            name="All products", includes_all_products=True)
13
-
14
-    def tearDown(self):
15
-        settings.OSCAR_OFFER_BLACKLIST_PRODUCT = None
16
-
17
-    def test_blacklisting_prevents_products_being_in_range(self):
18
-        settings.OSCAR_OFFER_BLACKLIST_PRODUCT = lambda p: True
19
-        prod = create_product()
20
-        self.assertFalse(self.range.contains_product(prod))
21
-
22
-    def test_blacklisting_can_use_product_class(self):
23
-        settings.OSCAR_OFFER_BLACKLIST_PRODUCT = (
24
-            lambda p: p.get_product_class().name == 'giftcard')
25
-        prod = create_product(product_class="giftcard")
26
-        self.assertFalse(self.range.contains_product(prod))
27
-
28
-    def test_blacklisting_doesnt_exlude_everything(self):
29
-        settings.OSCAR_OFFER_BLACKLIST_PRODUCT = (
30
-            lambda p: p.get_product_class().name == 'giftcard')
31
-        prod = create_product(product_class="book")
32
-        self.assertTrue(self.range.contains_product(prod))
33
-
34
-
35 7
 class TestWholeSiteRange(TestCase):
36 8
 
37 9
     def setUp(self):
@@ -75,7 +47,7 @@ class TestPartialRange(TestCase):
75 47
         self.assertFalse(self.range.contains_product(self.prod))
76 48
 
77 49
 
78
-class TestRangeModle(TestCase):
50
+class TestRangeModel(TestCase):
79 51
 
80 52
     def test_ensures_unique_slugs_are_used(self):
81 53
         first_range = models.Range.objects.create(name="Foo")

Loading…
Откажи
Сачувај