@transaction.non_atomic_requests
@require_POST
@require_certificate_permission
def generate_certificate_for_user(request):
 (params, response) = _validate_post_params(request.POST)
 if (response is not None):
  return response
 try:
  CourseOverview.get_from_id(params['course_key'])
 except CourseOverview.DoesNotExist:
  msg = _('The course {course_key} does not exist').format(course_key=params['course_key'])
  return HttpResponseBadRequest(msg)
 else:
  if (not CourseEnrollment.is_enrolled(params['user'], params['course_key'])):
   msg = _('User {username} is not enrolled in the course {course_key}').format(username=params['user'].username, course_key=params['course_key'])
   return HttpResponseBadRequest(msg)
  generate_certificates_for_students(request, params['course_key'], student_set='specific_student', specific_student_id=params['user'].id)
  return HttpResponse(200)

@ transaction . non_atomic_requests @ require_POST @ require_certificate_permission def generate_certificate_for_user ( request ) : ( params , response ) = _validate_post_params ( request . POST ) if ( response is not None ) : return response try : CourseOverview . get_from_id ( params [ 'course_key' ] ) except CourseOverview . DoesNotExist : msg = _ ( 'The course {course_key} does not exist' ) . format ( course_key = params [ 'course_key' ] ) return HttpResponseBadRequest ( msg ) else : if ( not CourseEnrollment . is_enrolled ( params [ 'user' ] , params [ 'course_key' ] ) ) : msg = _ ( 'User {username} is not enrolled in the course {course_key}' ) . format ( username = params [ 'user' ] . username , course_key = params [ 'course_key' ] ) return HttpResponseBadRequest ( msg ) generate_certificates_for_students ( request , params [ 'course_key' ] , student_set = 'specific_student' , specific_student_id = params [ 'user' ] . id ) return HttpResponse ( 200 )
generate certificates for a user .