Просмотр исходного кода

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 лет назад
Родитель
Сommit
fa1f8403fb

+ 1
- 0
oscar/apps/analytics/__init__.py Просмотреть файл

@@ -0,0 +1 @@
1
+from . import receivers  # noqa

+ 0
- 4
oscar/apps/analytics/models.py Просмотреть файл

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

+ 1
- 0
oscar/apps/catalogue/__init__.py Просмотреть файл

@@ -0,0 +1 @@
1
+from . import receivers  # noqa

+ 0
- 2
oscar/apps/catalogue/models.py Просмотреть файл

@@ -62,5 +62,3 @@ class Option(AbstractOption):
62 62
 
63 63
 class ProductImage(AbstractProductImage):
64 64
     pass
65
-
66
-from .receivers import *  # noqa

+ 1
- 0
oscar/apps/catalogue/receivers.py Просмотреть файл

@@ -26,6 +26,7 @@ def delete_image_files(sender, instance, **kwargs):
26 26
             except ThumbnailError:
27 27
                 pass
28 28
 
29
+
29 30
 # connect for all models with ImageFields - add as needed
30 31
 models_with_images = [ProductImage, Category]
31 32
 for sender in models_with_images:

+ 2
- 0
oscar/apps/customer/__init__.py Просмотреть файл

@@ -0,0 +1,2 @@
1
+from oscar.apps.customer.history import *  # noqa
2
+from oscar.apps.customer.alerts.receivers import *  # noqa

+ 0
- 4
oscar/apps/customer/models.py Просмотреть файл

@@ -15,7 +15,3 @@ class Notification(abstract_models.AbstractNotification):
15 15
 
16 16
 class ProductAlert(abstract_models.AbstractProductAlert):
17 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 Просмотреть файл

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

+ 1
- 0
oscar/apps/partner/__init__.py Просмотреть файл

@@ -0,0 +1 @@
1
+from oscar.apps.partner.receivers import *  # noqa

+ 0
- 3
oscar/apps/partner/models.py Просмотреть файл

@@ -17,6 +17,3 @@ class StockRecord(AbstractStockRecord):
17 17
 
18 18
 class StockAlert(AbstractStockAlert):
19 19
     pass
20
-
21
-
22
-from oscar.apps.partner.receivers import *  # noqa

+ 1
- 1
oscar/apps/shipping/models.py Просмотреть файл

@@ -116,7 +116,7 @@ class WeightBased(ShippingMethod):
116 116
 
117 117
     @property
118 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 120
         # requires shipping or not.  It is assumed that if something has a
121 121
         # weight, then it requires shipping.
122 122
         scales = Scales(attribute_code=self.weight_attribute,

Загрузка…
Отмена
Сохранить