Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
fix: updated api to change voucher name
Browse files Browse the repository at this point in the history
  • Loading branch information
zubair-ce07 committed Sep 26, 2023
1 parent c1c5bfe commit 0871938
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ecommerce/extensions/api/v2/views/coupons.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,15 @@ def update(self, request, *args, **kwargs):

def update_voucher_data(self, request_data, vouchers):
data = self.create_update_data_dict(data=request_data, fields=CouponVouchers.UPDATEABLE_VOUCHER_FIELDS)

if data:
vouchers.update(**data)
if 'name' in data:
for voucher in vouchers:
voucher_data = data.copy()
voucher_data['name'] = "%s - %d" % (voucher_data['name'], voucher.id + 1)
voucher.update(**voucher_data)
else:
vouchers.update(**data)

def create_update_data_dict(self, data, fields):
"""
Expand Down

0 comments on commit 0871938

Please sign in to comment.