summaryrefslogtreecommitdiffstats
path: root/app/controllers/comments_controller.rb
diff options
context:
space:
mode:
authorMarius Mathiesen <marius@shortcut.no>2009-10-12 12:22:13 +0200
committerJohan Sørensen <johan@johansorensen.com>2009-11-04 15:23:21 +0100
commitd7a184c7762eb74ad34896eaa6b46c230b84c9c0 (patch)
tree379addaf8a48ca2fc9b772c96df4e9ebc10d2fd7 /app/controllers/comments_controller.rb
parent93af6da17cdd98ee7d61fdeb7975a7eb0ac3fdfa (diff)
downloadgitorious-mainline-outdated-d7a184c7762eb74ad34896eaa6b46c230b84c9c0.zip
gitorious-mainline-outdated-d7a184c7762eb74ad34896eaa6b46c230b84c9c0.tar.gz
gitorious-mainline-outdated-d7a184c7762eb74ad34896eaa6b46c230b84c9c0.tar.bz2
Code cleanup in CommentsController
Note: all ajax requests are now sent with text/javascript Accept headers. This means they are interpreted as format.js in the controllers
Diffstat (limited to 'app/controllers/comments_controller.rb')
-rw-r--r--app/controllers/comments_controller.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index e47bada..87b6150 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -53,16 +53,10 @@ class CommentsController < ApplicationController
@comment.user = current_user
@comment.state = state
@comment.project = @project
+ render_or_redirect
+ end
- if MergeRequestVersion === @target
- if @comment.save
- render :nothing => true, :status => :created
- else
- render :text => "Clean up your mess", :status => :not_acceptable
- end
- return
- end
-
+ def render_or_redirect
respond_to do |format|
if @comment.save
create_new_commented_posted_event
@@ -74,10 +68,18 @@ class CommentsController < ApplicationController
redirect_to repo_owner_path(@repository, :project_repository_commit_path, @project, @repository, @comment.sha1)
end
end
+ format.js do
+ render :nothing => true, :status => :created
+ end
else
format.html { render :action => "new" }
+ format.js {render :nothing => true, :status => :not_acceptable}
end
- end
+ end
+ end
+
+ def applies_to_merge_request_version?
+ MergeRequestVersion === @target
end
protected
@@ -105,6 +107,7 @@ class CommentsController < ApplicationController
def create_new_commented_posted_event
# def create_event(action_id, target, user, data = nil, body = nil, date = Time.now.utc)
+ return if applies_to_merge_request_version?
if @target == @repository
@project.create_event(Action::COMMENT, @repository, current_user, @comment.to_param, "Repository")
else