Przeglądaj źródła

Import signal receivers in __init__.py (not models.py)

This is to avoid circular import issues as most receivers.py modules
also import models.  It's not entirely clear what circumstances are
required to get the circular import - it seems to be when using
django-debug-toolbar>=1.0, which changes the way the URLs are
monkey-patched.

This changes adopts the recommended practice for importing signal
receivers:

- https://groups.google.com/forum/#!msg/django-developers/PReHoxwwG_c/M-asj72ks7YJ
- http://stackoverflow.com/a/14192257/25517

Fixes #1125 (I think)
master
David Winterbottom 12 lat temu
rodzic
commit
fa1f8403fb

+ 1
- 0
oscar/apps/analytics/__init__.py Wyświetl plik

1
+from . import receivers  # noqa

+ 0
- 4
oscar/apps/analytics/models.py Wyświetl plik

17
 
17
 
18
 class UserSearch(AbstractUserSearch):
18
 class UserSearch(AbstractUserSearch):
19
     pass
19
     pass
20
-
21
-
22
-# Import receiver functions
23
-from oscar.apps.analytics.receivers import *  # noqa

+ 1
- 0
oscar/apps/catalogue/__init__.py Wyświetl plik

1
+from . import receivers  # noqa

+ 0
- 2
oscar/apps/catalogue/models.py Wyświetl plik

62
 
62
 
63
 class ProductImage(AbstractProductImage):
63
 class ProductImage(AbstractProductImage):
64
     pass
64
     pass
65
-
66
-from .receivers import *  # noqa

+ 1
- 0
oscar/apps/catalogue/receivers.py Wyświetl plik

26
             except ThumbnailError:
26
             except ThumbnailError:
27
                 pass
27
                 pass
28
 
28
 
29
+
29
 # connect for all models with ImageFields - add as needed
30
 # connect for all models with ImageFields - add as needed
30
 models_with_images = [ProductImage, Category]
31
 models_with_images = [ProductImage, Category]
31
 for sender in models_with_images:
32
 for sender in models_with_images:

+ 2
- 0
oscar/apps/customer/__init__.py Wyświetl plik

1
+from oscar.apps.customer.history import *  # noqa
2
+from oscar.apps.customer.alerts.receivers import *  # noqa

+ 0
- 4
oscar/apps/customer/models.py Wyświetl plik

15
 
15
 
16
 class ProductAlert(abstract_models.AbstractProductAlert):
16
 class ProductAlert(abstract_models.AbstractProductAlert):
17
     pass
17
     pass
18
-
19
-
20
-from oscar.apps.customer.history import *  # noqa
21
-from oscar.apps.customer.alerts.receivers import *  # noqa

+ 1
- 0
oscar/apps/offer/receivers.py Wyświetl plik

3
 from django.db.models import get_model
3
 from django.db.models import get_model
4
 
4
 
5
 from oscar.apps.basket.abstract_models import AbstractBasket
5
 from oscar.apps.basket.abstract_models import AbstractBasket
6
+
6
 Voucher = get_model('voucher', 'Voucher')
7
 Voucher = get_model('voucher', 'Voucher')
7
 OrderDiscount = get_model('order', 'OrderDiscount')
8
 OrderDiscount = get_model('order', 'OrderDiscount')
8
 ConditionalOffer = get_model('offer', 'ConditionalOffer')
9
 ConditionalOffer = get_model('offer', 'ConditionalOffer')

+ 1
- 0
oscar/apps/partner/__init__.py Wyświetl plik

1
+from oscar.apps.partner.receivers import *  # noqa

+ 0
- 3
oscar/apps/partner/models.py Wyświetl plik

17
 
17
 
18
 class StockAlert(AbstractStockAlert):
18
 class StockAlert(AbstractStockAlert):
19
     pass
19
     pass
20
-
21
-
22
-from oscar.apps.partner.receivers import *  # noqa

+ 1
- 1
oscar/apps/shipping/models.py Wyświetl plik

116
 
116
 
117
     @property
117
     @property
118
     def charge_incl_tax(self):
118
     def charge_incl_tax(self):
119
-        # Note, when weighing the basket, we don't check whether the item
119
+        # Note, when weighing the basket, we don't check whether the item
120
         # requires shipping or not.  It is assumed that if something has a
120
         # requires shipping or not.  It is assumed that if something has a
121
         # weight, then it requires shipping.
121
         # weight, then it requires shipping.
122
         scales = Scales(attribute_code=self.weight_attribute,
122
         scales = Scales(attribute_code=self.weight_attribute,

Ładowanie…
Anuluj
Zapisz