Merge branch 'master' into moderation
[rails.git] / app / controllers / issue_comments_controller.rb
1 class IssueCommentsController < ApplicationController
2   layout "site"
3
4   before_action :authorize_web
5   before_action :require_user
6   before_action :check_permission
7
8   def create
9     @issue = Issue.find(params[:issue_id])
10     comment = @issue.comments.build(issue_comment_params)
11     comment.user = current_user
12     # if params[:reassign]
13     #   reassign_issue
14     #   @issue_comment.reassign = true
15     # end
16     comment.save!
17     notice = t("issues.comment.comment_created")
18     redirect_to @issue, :notice => notice
19   end
20
21   private
22
23   def issue_comment_params
24     params.require(:issue_comment).permit(:body)
25   end
26
27   def check_permission
28     unless current_user.administrator? || current_user.moderator?
29       flash[:error] = t("application.require_admin.not_an_admin")
30       redirect_to root_path
31     end
32   end
33 end