parameters: (request, method, obj_type, obj_id)
return_statement: return render(request, "error.html", {'error':'Expected AJAX/POST'})
docstring: Add/update a comment for a top-level object. Should be an AJAX POST.
  
      :param request: Django request object (Required)
      :type request: :class:`django.http.HttpRequest`
      :param method: If this is a new comment or an update (set to "update").
      :type method: str
      :param obj_type: The type of the top-level object.
      :type obj_type: str
      :param obj_id: The ObjectId of the top-level object.
      :type obj_id: str
      :returns: :class:`django.http.HttpResponse`
docstring_summary: Add/update a comment for a top-level object. Should be an AJAX POST.
docstring_tokens: Add / update a comment for a top - level object . Should be an AJAX POST .
function: def add_update_comment(request, method, obj_type, obj_id):
      """
      Add/update a comment for a top-level object. Should be an AJAX POST.
  
      :param request: Django request object (Required)
      :type request: :class:`django.http.HttpRequest`
      :param method: If this is a new comment or an update (set to "update").
      :type method: str
      :param obj_type: The type of the top-level object.
      :type obj_type: str
      :param obj_id: The ObjectId of the top-level object.
      :type obj_id: str
      :returns: :class:`django.http.HttpResponse`
      """
  
      if request.method == "POST" and request.is_ajax():
          form = AddCommentForm(request.POST)
          if form.is_valid():
              cleaned_data = form.cleaned_data
              subscr = cleaned_data.get('subscribable', False)
              user = request.user
              acl = get_acl_object(obj_type)
              if method == "update":
                  if user.has_access_to(acl.COMMENTS_EDIT):
                      return comment_update(cleaned_data, obj_type, obj_id,
                                            subscr, user.username)
                  else:
                      result = {"success":False,
                                "message":"User does not have permission to edit comments."}
                      return HttpResponse(json.dumps(result),
                                          content_type="application/json")
              else:
                  if user.has_access_to(acl.COMMENTS_ADD):
                      return comment_add(cleaned_data, obj_type, obj_id, method,
                                         subscr, user.username)
                  else:
                      result = {"success":False,
                                "message":"User does not have permission to add comments."}
                      return HttpResponse(json.dumps(result),
                                          content_type="application/json")
  
          return HttpResponse(json.dumps({'success':False,
                                          'form':form.as_table()}),
                              content_type="application/json")
      return render(request, "error.html", {'error':'Expected AJAX/POST'})
function_tokens: def add_update_comment ( request , method , obj_type , obj_id ) : if request . method == "POST" and request . is_ajax ( ) : form = AddCommentForm ( request . POST ) if form . is_valid ( ) : cleaned_data = form . cleaned_data subscr = cleaned_data . get ( 'subscribable' , False ) user = request . user acl = get_acl_object ( obj_type ) if method == "update" : if user . has_access_to ( acl . COMMENTS_EDIT ) : return comment_update ( cleaned_data , obj_type , obj_id , subscr , user . username ) else : result = { "success" : False , "message" : "User does not have permission to edit comments." } return HttpResponse ( json . dumps ( result ) , content_type = "application/json" ) else : if user . has_access_to ( acl . COMMENTS_ADD ) : return comment_add ( cleaned_data , obj_type , obj_id , method , subscr , user . username ) else : result = { "success" : False , "message" : "User does not have permission to add comments." } return HttpResponse ( json . dumps ( result ) , content_type = "application/json" ) return HttpResponse ( json . dumps ( { 'success' : False , 'form' : form . as_table ( ) } ) , content_type = "application/json" ) return render ( request , "error.html" , { 'error' : 'Expected AJAX/POST' } )