Skip to content

Commit

Permalink
create dummy function and classes to use when oscar is not installed,…
Browse files Browse the repository at this point in the history
… Application, DatePickerInput, currency, ...
  • Loading branch information
wtayyeb committed Jul 18, 2016
1 parent 7452924 commit f8c72db
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/oscar_accounts/api/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.conf.urls import patterns, url
from django.views.decorators.csrf import csrf_exempt
from oscar.core.application import Application

from oscar_accounts.api import decorators, views
from oscar_accounts.compact_oscar import Application


class APIApplication(Application):
Expand Down
2 changes: 1 addition & 1 deletion src/oscar_accounts/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from django.shortcuts import get_object_or_404
from django.utils import timezone
from django.views import generic
from oscar.core.loading import get_model

from oscar_accounts import codes, exceptions, facade, names
from oscar_accounts.api import errors
from oscar_accounts.compact_oscar import get_model

Account = get_model('oscar_accounts', 'Account')
AccountType = get_model('oscar_accounts', 'AccountType')
Expand Down
4 changes: 2 additions & 2 deletions src/oscar_accounts/checkout/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django import forms
from django.utils.translation import ugettext_lazy as _
from oscar.core.loading import get_model
from oscar.templatetags.currency_filters import currency

from oscar_accounts.compact_oscar import get_model, currency

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

Expand Down
3 changes: 1 addition & 2 deletions src/oscar_accounts/checkout/gateway.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.utils.translation import ugettext_lazy as _
from oscar.apps.payment.exceptions import UnableToTakePayment
from oscar.core.loading import get_model

from oscar_accounts import codes, core, exceptions, facade
from oscar_accounts.compact_oscar import get_model, UnableToTakePayment

Account = get_model('oscar_accounts', 'Account')
Transfer = get_model('oscar_accounts', 'Transfer')
Expand Down
26 changes: 26 additions & 0 deletions src/oscar_accounts/compact_oscar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.apps.config import MODELS_MODULE_NAME
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, AppRegistryNotReady
from django import forms

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

# from oscar.apps.payment.exceptions
class UnableToTakePayment(Exception):
"""
Exception to be used for ANTICIPATED payment errors (eg card number wrong,
expiry date has passed). The message passed here will be shown to the end
user.
"""

# dummy for oscar.templatetags.currency_filters.currency
def currency(value, currency=None):
return value

# dummy for oscar.forms.widgets.DatePickerInput
DatePickerInput = forms.DateInput

# dummy for oscar.application.Application
class Application(object):
def post_process_urls(self, urlpatterns):
return urlpatterns


else: # oscar is installed, use it.
from oscar.apps.payment.exceptions import UnableToTakePayment
from oscar.core.application import Application
from oscar.core.compat import AUTH_USER_MODEL
from oscar.core.loading import get_model, is_model_registered
from oscar.forms.widgets import DatePickerInput
from oscar.templatetags.currency_filters import currency

2 changes: 1 addition & 1 deletion src/oscar_accounts/dashboard/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf.urls import patterns, url
from django.contrib.admin.views.decorators import staff_member_required
from oscar.core.application import Application

from oscar_accounts.compact_oscar import Application
from oscar_accounts.dashboard import views


Expand Down
4 changes: 1 addition & 3 deletions src/oscar_accounts/dashboard/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from django.conf import settings
from django.core import exceptions
from django.utils.translation import ugettext_lazy as _
from oscar.core.loading import get_model
from oscar.forms.widgets import DatePickerInput
from oscar.templatetags.currency_filters import currency

from oscar_accounts import codes, names
from oscar_accounts.compact_oscar import get_model, currency, DatePickerInput

Account = get_model('oscar_accounts', 'Account')
AccountType = get_model('oscar_accounts', 'AccountType')
Expand Down
2 changes: 1 addition & 1 deletion src/oscar_accounts/dashboard/reports.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from decimal import Decimal as D

from django.db.models import Sum
from oscar.core.loading import get_model

from oscar_accounts import names
from oscar_accounts.compact_oscar import get_model

AccountType = get_model('oscar_accounts', 'AccountType')
Account = get_model('oscar_accounts', 'Account')
Expand Down
3 changes: 1 addition & 2 deletions src/oscar_accounts/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.views import generic
from oscar.core.loading import get_model
from oscar.templatetags.currency_filters import currency

from oscar_accounts import exceptions, facade, names
from oscar_accounts.compact_oscar import get_model, currency
from oscar_accounts.dashboard import forms, reports

AccountType = get_model('oscar_accounts', 'AccountType')
Expand Down

0 comments on commit f8c72db

Please sign in to comment.