unless create_new_issue_params.blank?
@issue = Issue.find_or_initialize_by(create_new_issue_params)
path = 'issues.report_strings.' + @issue.reportable.class.name.to_s
- @report_strings_yaml = t( path)
+ @report_strings_yaml = t(path)
end
end
# TODO: Find better place to add these
admin_issues = [ 'DiaryEntry', 'DiaryComment', 'User']
- moderator_issues = []
+ moderator_issues = [ 'Changeset' ]
@issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id],params[:reportable_type])
def comment
@issue = Issue.find(params[:id])
- @issue_comment = @issue.comments.build(issue_comment_params)
- @issue_comment.commenter_user_id = @user.id
- if params[:reassign]
- reassign_issue
- @issue_comment.reassign = true
+ if issue_comment_params.blank?
+ notice = t('issues.comment.provide_details')
+ else
+ @issue_comment = @issue.comments.build(issue_comment_params)
+ @issue_comment.commenter_user_id = @user.id
+ if params[:reassign]
+ reassign_issue
+ @issue_comment.reassign = true
+ end
+ @issue_comment.save!
+ @issue.updated_by = @user.id
+ @issue.save!
+ notice = t('issues.comment.comment_created')
end
- @issue_comment.save!
- @issue.updated_by = @user.id
- @issue.save!
- redirect_to @issue
+ redirect_to @issue, notice: notice
end
# Status Transistions
def get_report_details
details = params[:report][:details] + "--||--"
- path = 'issues.report_strings.' + @issue.reportable.class.name.to_s
- @report_strings_yaml = t( path)
- @report_strings_yaml.each do |k,v|
- if params[k.to_sym]
- details = details + params[k.to_sym] + "--||--"
- end
- end
+ details = details + params[:report_type].to_s + "--||--"
return details
end
def check_report_params
- path = 'issues.report_strings.' + @issue.reportable.class.name.to_s
- @report_strings_yaml = t( path)
- if params[:report] and params[:report][:details]
- @report_strings_yaml.each do |k,v|
- if params[k.to_sym]
- return true
- end
- end
+ if params[:report] and params[:report][:details] and params[:report_type]
+ return true
end
return false
end
end
def check_permission
- unless @user.administrator?
+ unless @user.administrator? or @user.moderator?
flash[:error] = t('application.require_admin.not_an_admin')
redirect_to root_path
end