Skip to content

Commit

Permalink
Modified sale line serialization for cart #7211
Browse files Browse the repository at this point in the history
By default, the standard fields 'display_name', 'url', 'image' are
picked from the sale line's product. In downstream modules this
behaviour can be modified.
  • Loading branch information
PritishC committed Mar 4, 2015
1 parent 8bf3052 commit 816c587
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ def _add_or_update(self, product_id, quantity, action='set'):
values.update(SaleLine(**values).on_change_quantity())

for key, value in values.iteritems():
# This can be removed in 3.4 and call on_change on
# instance
if '.' not in key:
setattr(order_line, key, value)
return order_line
Expand Down Expand Up @@ -164,6 +162,13 @@ def serialize(self, purpose=None):
if purpose == 'cart':
res.update({
'id': self.id,
'display_name': self.description or self.product.name,
'url': self.product.get_absolute_url(_external=True),
'image': (
self.product.default_image.transform_command().thumbnail(
150, 150, 'a'
).url() if self.product.default_image else None
),
'product': self.product.serialize(purpose),
'quantity': number_format(self.quantity),
'unit': self.unit.symbol,
Expand Down

0 comments on commit 816c587

Please sign in to comment.