Skip to content

Commit f8c72db

Browse files
committed
create dummy function and classes to use when oscar is not installed, Application, DatePickerInput, currency, ...
1 parent 7452924 commit f8c72db

File tree

9 files changed

+35
-13
lines changed

9 files changed

+35
-13
lines changed

src/oscar_accounts/api/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from django.conf.urls import patterns, url
22
from django.views.decorators.csrf import csrf_exempt
3-
from oscar.core.application import Application
43

54
from oscar_accounts.api import decorators, views
5+
from oscar_accounts.compact_oscar import Application
66

77

88
class APIApplication(Application):

src/oscar_accounts/api/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from django.shortcuts import get_object_or_404
1010
from django.utils import timezone
1111
from django.views import generic
12-
from oscar.core.loading import get_model
1312

1413
from oscar_accounts import codes, exceptions, facade, names
1514
from oscar_accounts.api import errors
15+
from oscar_accounts.compact_oscar import get_model
1616

1717
Account = get_model('oscar_accounts', 'Account')
1818
AccountType = get_model('oscar_accounts', 'AccountType')

src/oscar_accounts/checkout/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
from django import forms
44
from django.utils.translation import ugettext_lazy as _
5-
from oscar.core.loading import get_model
6-
from oscar.templatetags.currency_filters import currency
5+
6+
from oscar_accounts.compact_oscar import get_model, currency
77

88
Account = get_model('oscar_accounts', 'Account')
99

src/oscar_accounts/checkout/gateway.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from django.utils.translation import ugettext_lazy as _
2-
from oscar.apps.payment.exceptions import UnableToTakePayment
3-
from oscar.core.loading import get_model
42

53
from oscar_accounts import codes, core, exceptions, facade
4+
from oscar_accounts.compact_oscar import get_model, UnableToTakePayment
65

76
Account = get_model('oscar_accounts', 'Account')
87
Transfer = get_model('oscar_accounts', 'Transfer')

src/oscar_accounts/compact_oscar.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.apps.config import MODELS_MODULE_NAME
88
from django.conf import settings
99
from django.core.exceptions import ImproperlyConfigured, AppRegistryNotReady
10+
from django import forms
1011

1112
# from oscar.core.compat
1213
# A setting that can be used in foreign key declarations
@@ -63,7 +64,32 @@ def is_model_registered(app_label, model_name):
6364
else:
6465
return True
6566

67+
# from oscar.apps.payment.exceptions
68+
class UnableToTakePayment(Exception):
69+
"""
70+
Exception to be used for ANTICIPATED payment errors (eg card number wrong,
71+
expiry date has passed). The message passed here will be shown to the end
72+
user.
73+
"""
74+
75+
# dummy for oscar.templatetags.currency_filters.currency
76+
def currency(value, currency=None):
77+
return value
78+
79+
# dummy for oscar.forms.widgets.DatePickerInput
80+
DatePickerInput = forms.DateInput
81+
82+
# dummy for oscar.application.Application
83+
class Application(object):
84+
def post_process_urls(self, urlpatterns):
85+
return urlpatterns
86+
87+
6688
else: # oscar is installed, use it.
89+
from oscar.apps.payment.exceptions import UnableToTakePayment
90+
from oscar.core.application import Application
6791
from oscar.core.compat import AUTH_USER_MODEL
6892
from oscar.core.loading import get_model, is_model_registered
93+
from oscar.forms.widgets import DatePickerInput
94+
from oscar.templatetags.currency_filters import currency
6995

src/oscar_accounts/dashboard/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.conf.urls import patterns, url
22
from django.contrib.admin.views.decorators import staff_member_required
3-
from oscar.core.application import Application
43

4+
from oscar_accounts.compact_oscar import Application
55
from oscar_accounts.dashboard import views
66

77

src/oscar_accounts/dashboard/forms.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
from django.conf import settings
55
from django.core import exceptions
66
from django.utils.translation import ugettext_lazy as _
7-
from oscar.core.loading import get_model
8-
from oscar.forms.widgets import DatePickerInput
9-
from oscar.templatetags.currency_filters import currency
107

118
from oscar_accounts import codes, names
9+
from oscar_accounts.compact_oscar import get_model, currency, DatePickerInput
1210

1311
Account = get_model('oscar_accounts', 'Account')
1412
AccountType = get_model('oscar_accounts', 'AccountType')

src/oscar_accounts/dashboard/reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from decimal import Decimal as D
22

33
from django.db.models import Sum
4-
from oscar.core.loading import get_model
54

65
from oscar_accounts import names
6+
from oscar_accounts.compact_oscar import get_model
77

88
AccountType = get_model('oscar_accounts', 'AccountType')
99
Account = get_model('oscar_accounts', 'Account')

src/oscar_accounts/dashboard/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
from django.utils import timezone
1010
from django.utils.translation import ugettext_lazy as _
1111
from django.views import generic
12-
from oscar.core.loading import get_model
13-
from oscar.templatetags.currency_filters import currency
1412

1513
from oscar_accounts import exceptions, facade, names
14+
from oscar_accounts.compact_oscar import get_model, currency
1615
from oscar_accounts.dashboard import forms, reports
1716

1817
AccountType = get_model('oscar_accounts', 'AccountType')

0 commit comments

Comments
 (0)