diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-08-18 15:01:35 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-08-18 15:01:35 +0000 |
commit | 1f8d396e3f12ec177fec0dea6a4a7c39c00fe496 (patch) | |
tree | 1ddd1116f61d95f4b18a5c6088fb35eb6e5e6dd0 /app/controllers | |
parent | 3eff27344b0bef7703ba248d0a2312bfca95c182 (diff) | |
download | redmine-1f8d396e3f12ec177fec0dea6a4a7c39c00fe496.tar.gz redmine-1f8d396e3f12ec177fec0dea6a4a7c39c00fe496.zip |
Refactor: move IssuesController#preview to a new controller.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3946 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/issues_controller.rb | 15 | ||||
-rw-r--r-- | app/controllers/previews_controller.rb | 28 |
2 files changed, 28 insertions, 15 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 4981f43ee..239c23e71 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -301,21 +301,6 @@ class IssuesController < ApplicationController render :partial => 'attributes' end - def preview - @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank? - if @issue - @attachements = @issue.attachments - @description = params[:issue] && params[:issue][:description] - if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n") - @description = nil - end - @notes = params[:notes] - else - @description = (params[:issue] ? params[:issue][:description] : nil) - end - render :layout => false - end - private def find_issue @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) diff --git a/app/controllers/previews_controller.rb b/app/controllers/previews_controller.rb new file mode 100644 index 000000000..e1c644653 --- /dev/null +++ b/app/controllers/previews_controller.rb @@ -0,0 +1,28 @@ +class PreviewsController < ApplicationController + before_filter :find_project + + def issue + @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank? + if @issue + @attachements = @issue.attachments + @description = params[:issue] && params[:issue][:description] + if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n") + @description = nil + end + @notes = params[:notes] + else + @description = (params[:issue] ? params[:issue][:description] : nil) + end + render :layout => false + end + + private + + def find_project + project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id] + @project = Project.find(project_id) + rescue ActiveRecord::RecordNotFound + render_404 + end + +end |