@require_POST
@login_required
def update_coupon(request, course_id):
 coupon_id = request.POST.get('coupon_id', None)
 if (not coupon_id):
  return JsonResponse({'message': _('coupon id not found')}, status=400)
 try:
  coupon = Coupon.objects.get(pk=coupon_id)
 except ObjectDoesNotExist:
  return JsonResponse({'message': _('coupon with the coupon id ({coupon_id}) DoesNotExist').format(coupon_id=coupon_id)}, status=400)
 description = request.POST.get('description')
 coupon.description = description
 coupon.save()
 return JsonResponse({'message': _('coupon with the coupon id ({coupon_id}) updated Successfully').format(coupon_id=coupon_id)})

@ require_POST @ login_required def update_coupon ( request , course_id ) : coupon_id = request . POST . get ( 'coupon_id' , None ) if ( not coupon_id ) : return JsonResponse ( { 'message' : _ ( 'coupon id not found' ) } , status = 400 ) try : coupon = Coupon . objects . get ( pk = coupon_id ) except ObjectDoesNotExist : return JsonResponse ( { 'message' : _ ( 'coupon with the coupon id ({coupon_id}) DoesNotExist' ) . format ( coupon_id = coupon_id ) } , status = 400 ) description = request . POST . get ( 'description' ) coupon . description = description coupon . save ( ) return JsonResponse ( { 'message' : _ ( 'coupon with the coupon id ({coupon_id}) updated Successfully' ) . format ( coupon_id = coupon_id ) } )
update the coupon object in the database .