@require_POST
@login_required
def get_coupon_info(request, course_id):
 coupon_id = request.POST.get('id', None)
 if (not coupon_id):
  return JsonResponse({'message': _('coupon id not found')}, 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)
 expiry_date = coupon.display_expiry_date
 return JsonResponse({'coupon_code': coupon.code, 'coupon_description': coupon.description, 'coupon_course_id': coupon.course_id.to_deprecated_string(), 'coupon_discount': coupon.percentage_discount, 'expiry_date': expiry_date, 'message': _('coupon with the coupon id ({coupon_id}) updated successfully').format(coupon_id=coupon_id)})

@ require_POST @ login_required def get_coupon_info ( request , course_id ) : coupon_id = request . POST . get ( 'id' , None ) if ( not coupon_id ) : return JsonResponse ( { 'message' : _ ( 'coupon id not found' ) } , 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 ) expiry_date = coupon . display_expiry_date return JsonResponse ( { 'coupon_code' : coupon . code , 'coupon_description' : coupon . description , 'coupon_course_id' : coupon . course_id . to_deprecated_string ( ) , 'coupon_discount' : coupon . percentage_discount , 'expiry_date' : expiry_date , 'message' : _ ( 'coupon with the coupon id ({coupon_id}) updated successfully' ) . format ( coupon_id = coupon_id ) } )
get the coupon information to display in the pop up form .