passing request to get current_site
Possibility of multiple may be used. So, we can use request object to get current site.
@@ -38,7 +38,7 @@ class OrderCreator(object):
def place_order(self, basket, total, # noqa (too complex (12))
shipping_method, shipping_charge, user=None,
shipping_address=None, billing_address=None,
- order_number=None, status=None, **kwargs):
+ order_number=None, status=None, req=None, **kwargs):
"""
Placing an order involves creating all the relevant models based on the
basket and session data.
@@ -61,7 +61,7 @@ class OrderCreator(object):
# Ok - everything seems to be in order, let's place the order
order = self.create_order_model(
user, basket, shipping_address, shipping_method, shipping_charge,
- billing_address, total, order_number, status, **kwargs)
+ billing_address, total, order_number, status, req, **kwargs)
for line in basket.all_lines():
self.create_line_models(order, line)
self.update_stock_records(line)
@@ -96,12 +96,13 @@ class OrderCreator(object):
def create_order_model(self, user, basket, shipping_address,
shipping_method, shipping_charge, billing_address,
- total, order_number, status, **extra_order_fields):
+ total, order_number, status, req, **extra_order_fields):
"""
Create an order model.
"""
order_data = {'basket': basket,
'number': order_number,
+ 'site': Site._default_manager.get_current(req),
'currency': total.currency,
'total_incl_tax': total.incl_tax,
'total_excl_tax': total.excl_tax,
