From c8ec4ec0eb50def2961cf61299d5729efa510c30 Mon Sep 17 00:00:00 2001 From: zubair-ce07 Date: Tue, 26 Sep 2023 16:08:32 +0500 Subject: [PATCH] fix: updated api to change voucher name --- ecommerce/extensions/api/v2/views/coupons.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ecommerce/extensions/api/v2/views/coupons.py b/ecommerce/extensions/api/v2/views/coupons.py index e46c95cb324..d42499ee0e8 100644 --- a/ecommerce/extensions/api/v2/views/coupons.py +++ b/ecommerce/extensions/api/v2/views/coupons.py @@ -376,12 +376,11 @@ def update_voucher_data(self, request_data, vouchers): if data: if 'name' in data: + data.pop('name') for voucher in vouchers: - voucher_data = data.copy() - voucher_data['name'] = "%s - %d" % (voucher_data['name'], voucher.id + 1) - voucher.save(**voucher_data) - else: - vouchers.update(**data) + voucher.name = "%s - %d" % (data['name'], voucher.id + 1) + + vouchers.update(**data) def create_update_data_dict(self, data, fields): """