Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Fix import issues with receivers and models
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Vetter committed Nov 4, 2013
1 parent a1dff32 commit 7871f91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
3 changes: 2 additions & 1 deletion oscar_mws/feeds/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def get_value_element(self, attr_name):

attr_value = self._get_value_from(self, pyattr)
if attr_value is None:
attr_value = self._get_value_from(self.product.amazon_profile, pyattr)
attr_value = self._get_value_from(
self.product.amazon_profile, pyattr)
if attr_value is None:
attr_value = self._get_value_from(self.product, pyattr)

Expand Down
27 changes: 13 additions & 14 deletions oscar_mws/fulfillment/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,26 @@
FulfillmentOrderLine = get_model('oscar_mws', 'FulfillmentOrderLine')


try:
find_fulfillment_merchant = load_class(
getattr(settings, 'MWS_FULFILLMENT_MERCHANT_FINDER', None)
)
except ImportError:
raise ImproperlyConfigured(
"no fulfillment merchant finder callable configured in "
"MWS_FULFILLMENT_MERCHANT_FINDER setting. Check your settings "
"file and try again."
)


class FulfillmentOrderCreator(object):
order_adapter_class = OrderAdapter

def __init__(self, order_adapter_class=None):
custom_adapter = getattr(settings, 'MWS_ORDER_ADAPTER', None)
self.errors = {}

if custom_adapter:
self.order_adapter_class = load_class(custom_adapter)

self.errors = {}
try:
self.find_fulfillment_merchant = load_class(
getattr(settings, 'MWS_FULFILLMENT_MERCHANT_FINDER', None)
)
except ImportError:
raise ImproperlyConfigured(
"no fulfillment merchant finder callable configured in "
"MWS_FULFILLMENT_MERCHANT_FINDER setting. Check your settings "
"file and try again."
)

def get_order_adapter(self, order):
return self.order_adapter_class(order=order)
Expand All @@ -45,7 +44,7 @@ def create_fulfillment_order(self, order, lines=None, **kwargs):
for address in adapter.addresses:
fulfillment_id = adapter.get_seller_fulfillment_order_id(address)

merchant = find_fulfillment_merchant(order, address)
merchant = self.find_fulfillment_merchant(order, address)
if not merchant:
self.errors[fulfillment_id] = _(
"could not find suitable merchant for fulfillemnt order "
Expand Down
4 changes: 2 additions & 2 deletions oscar_mws/receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

from django.utils.translation import ugettext_lazy as _

from oscar_mws.fulfillment.creator import FulfillmentOrderCreator

logger = logging.getLogger('oscar_mws')


def submit_order_to_mws(order, user, **kwargs):
if kwargs.get('raw', False):
return

from oscar_mws.fulfillment.creator import FulfillmentOrderCreator

order_creator = FulfillmentOrderCreator()
submitted_orders = order_creator.create_fulfillment_order(order)

Expand Down

0 comments on commit 7871f91

Please sign in to comment.