Quellcode durchsuchen

Only register receivers in models.py for Django < 1.7

In Django >= 1.7 this will be done via the AppConfig
master
Michael van Tellingen vor 11 Jahren
Ursprung
Commit
c420a4eac9

+ 4
- 1
oscar/apps/analytics/models.py Datei anzeigen

@@ -1,3 +1,5 @@
1
+import django
2
+
1 3
 from oscar.apps.analytics.abstract_models import (
2 4
     AbstractProductRecord, AbstractUserRecord,
3 5
     AbstractUserProductView, AbstractUserSearch)
@@ -19,4 +21,5 @@ class UserSearch(AbstractUserSearch):
19 21
     pass
20 22
 
21 23
 
22
-from .receivers import *  # noqa
24
+if django.VERSION < (1, 7):
25
+    from . import receivers  # noqa

+ 4
- 1
oscar/apps/catalogue/models.py Datei anzeigen

@@ -1,3 +1,5 @@
1
+import django
2
+
1 3
 """
2 4
 Vanilla product models
3 5
 """
@@ -48,4 +50,5 @@ class ProductImage(AbstractProductImage):
48 50
     pass
49 51
 
50 52
 
51
-from .receivers import *  # noqa
53
+if django.VERSION < (1, 7):
54
+    from . import receivers

+ 5
- 2
oscar/apps/customer/models.py Datei anzeigen

@@ -1,3 +1,5 @@
1
+import django
2
+
1 3
 from oscar.apps.customer import abstract_models
2 4
 
3 5
 
@@ -17,5 +19,6 @@ class ProductAlert(abstract_models.AbstractProductAlert):
17 19
     pass
18 20
 
19 21
 
20
-from oscar.apps.customer.history import *  # noqa
21
-from oscar.apps.customer.alerts.receivers import *  # noqa
22
+if django.VERSION < (1, 7):
23
+    from oscar.apps.customer.history import *  # noqa
24
+    from .alerts import receivers  # noqa

+ 0
- 1
oscar/apps/order/models.py Datei anzeigen

@@ -2,7 +2,6 @@ from oscar.apps.order.abstract_models import *  # noqa
2 2
 from oscar.apps.address.abstract_models import (AbstractShippingAddress,
3 3
                                                 AbstractBillingAddress)
4 4
 
5
-
6 5
 class Order(AbstractOrder):
7 6
     pass
8 7
 

+ 17
- 9
oscar/apps/partner/models.py Datei anzeigen

@@ -1,22 +1,30 @@
1
+import django
2
+
3
+from oscar.core.loading import model_registered
1 4
 from oscar.apps.address.abstract_models import AbstractPartnerAddress
2 5
 from oscar.apps.partner.abstract_models import (
3 6
     AbstractPartner, AbstractStockRecord, AbstractStockAlert)
4 7
 
5 8
 
6
-class Partner(AbstractPartner):
7
-    pass
9
+if not model_registered('partner', 'Partner'):
10
+    class Partner(AbstractPartner):
11
+        pass
8 12
 
9 13
 
10
-class PartnerAddress(AbstractPartnerAddress):
11
-    pass
14
+if not model_registered('partner', 'PartnerAddress'):
15
+    class PartnerAddress(AbstractPartnerAddress):
16
+        pass
12 17
 
13 18
 
14
-class StockRecord(AbstractStockRecord):
15
-    pass
19
+if not model_registered('partner', 'StockRecord'):
20
+    class StockRecord(AbstractStockRecord):
21
+        pass
16 22
 
17 23
 
18
-class StockAlert(AbstractStockAlert):
19
-    pass
24
+if not model_registered('partner', 'StockAlert'):
25
+    class StockAlert(AbstractStockAlert):
26
+        pass
20 27
 
21 28
 
22
-from oscar.apps.partner.receivers import *  # noqa
29
+if django.VERSION < (1, 7):
30
+    from . import receivers  # noqa

+ 0
- 1
oscar/apps/voucher/__init__.py Datei anzeigen

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

+ 6
- 0
oscar/apps/voucher/models.py Datei anzeigen

@@ -1,3 +1,5 @@
1
+import django
2
+
1 3
 from oscar.apps.voucher.abstract_models import (
2 4
     AbstractVoucher, AbstractVoucherApplication)
3 5
 
@@ -8,3 +10,7 @@ class Voucher(AbstractVoucher):
8 10
 
9 11
 class VoucherApplication(AbstractVoucherApplication):
10 12
     pass
13
+
14
+
15
+if django.VERSION < (1, 7):
16
+    from . import receivers  # noqa

Laden…
Abbrechen
Speichern