@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_POST
@login_required
def set_course_mode_price(request, course_id):
 try:
  course_price = int(request.POST['course_price'])
 except ValueError:
  return JsonResponse({'message': _('Please Enter the numeric value for the course price')}, status=400)
 currency = request.POST['currency']
 course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
 course_honor_mode = CourseMode.objects.filter(mode_slug='honor', course_id=course_key)
 if (not course_honor_mode):
  return JsonResponse({'message': _('CourseMode with the mode slug({mode_slug}) DoesNotExist').format(mode_slug='honor')}, status=400)
 CourseModesArchive.objects.create(course_id=course_id, mode_slug='honor', mode_display_name='Honor Code Certificate', min_price=course_honor_mode[0].min_price, currency=course_honor_mode[0].currency, expiration_datetime=datetime.datetime.now(pytz.utc), expiration_date=datetime.date.today())
 course_honor_mode.update(min_price=course_price, currency=currency)
 return JsonResponse({'message': _('CourseMode price updated successfully')})

@ ensure_csrf_cookie @ cache_control ( no_cache = True , no_store = True , must_revalidate = True ) @ require_POST @ login_required def set_course_mode_price ( request , course_id ) : try : course_price = int ( request . POST [ 'course_price' ] ) except ValueError : return JsonResponse ( { 'message' : _ ( 'Please Enter the numeric value for the course price' ) } , status = 400 ) currency = request . POST [ 'currency' ] course_key = SlashSeparatedCourseKey . from_deprecated_string ( course_id ) course_honor_mode = CourseMode . objects . filter ( mode_slug = 'honor' , course_id = course_key ) if ( not course_honor_mode ) : return JsonResponse ( { 'message' : _ ( 'CourseMode with the mode slug({mode_slug}) DoesNotExist' ) . format ( mode_slug = 'honor' ) } , status = 400 ) CourseModesArchive . objects . create ( course_id = course_id , mode_slug = 'honor' , mode_display_name = 'Honor Code Certificate' , min_price = course_honor_mode [ 0 ] . min_price , currency = course_honor_mode [ 0 ] . currency , expiration_datetime = datetime . datetime . now ( pytz . utc ) , expiration_date = datetime . date . today ( ) ) course_honor_mode . update ( min_price = course_price , currency = currency ) return JsonResponse ( { 'message' : _ ( 'CourseMode price updated successfully' ) } )
set the new course price and add new entry in the coursemodesarchive table .