def require_finance_admin(func):
 def wrapped(request, course_id):
  try:
   course_key = CourseKey.from_string(course_id)
  except InvalidKeyError:
   log.error(u'Unable to find course with course key %s', course_id)
   return HttpResponseNotFound()
  access = auth.user_has_role(request.user, CourseFinanceAdminRole(course_key))
  if access:
   return func(request, course_id)
  else:
   return HttpResponseForbidden()
 return wrapped

def require_finance_admin ( func ) : def wrapped ( request , course_id ) : try : course_key = CourseKey . from_string ( course_id ) except InvalidKeyError : log . error ( u'Unable to find course with course key %s' , course_id ) return HttpResponseNotFound ( ) access = auth . user_has_role ( request . user , CourseFinanceAdminRole ( course_key ) ) if access : return func ( request , course_id ) else : return HttpResponseForbidden ( ) return wrapped
decorator for checking finance administrator access before executing an http endpoint .