Sfoglia il codice sorgente

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 anni fa
parent
commit
8a03abb0bb

+ 0
- 20
docs/source/ref/settings.rst Vedi File

312
 Offer settings
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
 ``OSCAR_OFFER_ROUNDING_FUNCTION``
315
 ``OSCAR_OFFER_ROUNDING_FUNCTION``
336
 ---------------------------------
316
 ---------------------------------
337
 
317
 

+ 6
- 0
docs/source/releases/v0.8.rst Vedi File

490
   and not running an English locale, you will need to migrate the existing
490
   and not running an English locale, you will need to migrate the existing
491
   data to the English values.
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
 .. _rewritten: https://github.com/tangentlabs/django-oscar/commit/d8b4dbfed17be90846ea4bc47b5f7b39ad944c24
499
 .. _rewritten: https://github.com/tangentlabs/django-oscar/commit/d8b4dbfed17be90846ea4bc47b5f7b39ad944c24
494
 
500
 
495
 Basket line stockrecords
501
 Basket line stockrecords

+ 0
- 7
oscar/apps/offer/models.py Vedi File

843
         """
843
         """
844
         Check whether the passed product is part of this range
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
         # Delegate to a proxy class if one is provided
846
         # Delegate to a proxy class if one is provided
854
         if self.proxy_class:
847
         if self.proxy_class:
855
             return load_proxy(self.proxy_class)().contains_product(product)
848
             return load_proxy(self.proxy_class)().contains_product(product)

+ 0
- 3
oscar/defaults.py Vedi File

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

+ 1
- 29
tests/integration/offer/range_tests.py Vedi File

1
-from django.conf import settings
2
 from django.test import TestCase
1
 from django.test import TestCase
3
 
2
 
4
 from oscar.apps.offer import models
3
 from oscar.apps.offer import models
5
 from oscar.test.factories import create_product
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
 class TestWholeSiteRange(TestCase):
7
 class TestWholeSiteRange(TestCase):
36
 
8
 
37
     def setUp(self):
9
     def setUp(self):
75
         self.assertFalse(self.range.contains_product(self.prod))
47
         self.assertFalse(self.range.contains_product(self.prod))
76
 
48
 
77
 
49
 
78
-class TestRangeModle(TestCase):
50
+class TestRangeModel(TestCase):
79
 
51
 
80
     def test_ensures_unique_slugs_are_used(self):
52
     def test_ensures_unique_slugs_are_used(self):
81
         first_range = models.Range.objects.create(name="Foo")
53
         first_range = models.Range.objects.create(name="Foo")

Loading…
Annulla
Salva