@login_required
def course_notifications_handler(request, course_key_string=None, action_state_id=None):
 if ((not course_key_string) or (not action_state_id)):
  return HttpResponseBadRequest()
 response_format = (request.GET.get('format') or request.POST.get('format') or 'html')
 course_key = CourseKey.from_string(course_key_string)
 if ((response_format == 'json') or ('application/json' in request.META.get('HTTP_ACCEPT', 'application/json'))):
  if (not has_studio_write_access(request.user, course_key)):
   raise PermissionDenied()
  if (request.method == 'GET'):
   return _course_notifications_json_get(action_state_id)
  elif (request.method == 'DELETE'):
   return _dismiss_notification(request, action_state_id)
  elif (request.method == 'PUT'):
   raise NotImplementedError()
  elif (request.method == 'POST'):
   raise NotImplementedError()
  else:
   return HttpResponseBadRequest()
 else:
  return HttpResponseNotFound()

@ login_required def course_notifications_handler ( request , course_key_string = None , action_state_id = None ) : if ( ( not course_key_string ) or ( not action_state_id ) ) : return HttpResponseBadRequest ( ) response_format = ( request . GET . get ( 'format' ) or request . POST . get ( 'format' ) or 'html' ) course_key = CourseKey . from_string ( course_key_string ) if ( ( response_format == 'json' ) or ( 'application/json' in request . META . get ( 'HTTP_ACCEPT' , 'application/json' ) ) ) : if ( not has_studio_write_access ( request . user , course_key ) ) : raise PermissionDenied ( ) if ( request . method == 'GET' ) : return _course_notifications_json_get ( action_state_id ) elif ( request . method == 'DELETE' ) : return _dismiss_notification ( request , action_state_id ) elif ( request . method == 'PUT' ) : raise NotImplementedError ( ) elif ( request . method == 'POST' ) : raise NotImplementedError ( ) else : return HttpResponseBadRequest ( ) else : return HttpResponseNotFound ( )
handle incoming requests for notifications in a restful way .