@require_POST
@login_required
def remove_coupon(request, course_id):
 coupon_id = request.POST.get('id', None)
 if (not coupon_id):
  return JsonResponse({'message': _('coupon id is None')}, status=400)
 try:
  coupon = Coupon.objects.get(id=coupon_id)
 except ObjectDoesNotExist:
  return JsonResponse({'message': _('coupon with the coupon id ({coupon_id}) DoesNotExist').format(coupon_id=coupon_id)}, status=400)
 if (not coupon.is_active):
  return JsonResponse({'message': _('coupon with the coupon id ({coupon_id}) is already inactive').format(coupon_id=coupon_id)}, status=400)
 coupon.is_active = False
 coupon.save()
 return JsonResponse({'message': _('coupon with the coupon id ({coupon_id}) updated successfully').format(coupon_id=coupon_id)})

@ require_POST @ login_required def remove_coupon ( request , course_id ) : coupon_id = request . POST . get ( 'id' , None ) if ( not coupon_id ) : return JsonResponse ( { 'message' : _ ( 'coupon id is None' ) } , status = 400 ) try : coupon = Coupon . objects . get ( id = coupon_id ) except ObjectDoesNotExist : return JsonResponse ( { 'message' : _ ( 'coupon with the coupon id ({coupon_id}) DoesNotExist' ) . format ( coupon_id = coupon_id ) } , status = 400 ) if ( not coupon . is_active ) : return JsonResponse ( { 'message' : _ ( 'coupon with the coupon id ({coupon_id}) is already inactive' ) . format ( coupon_id = coupon_id ) } , status = 400 ) coupon . is_active = False coupon . save ( ) return JsonResponse ( { 'message' : _ ( 'coupon with the coupon id ({coupon_id}) updated successfully' ) . format ( coupon_id = coupon_id ) } )
remove the coupon against the coupon id set the coupon is_active flag to false .