annotate app/controllers/previews_controller.rb @ 36:de76cd3e8c8e cc-branches

* Probably abortive experiments in extracting the branch from Hg
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 20 Oct 2010 10:07:29 +0100
parents 1d32c0a0efbf
children 94944d00e43c
rev   line source
Chris@14 1 class PreviewsController < ApplicationController
Chris@14 2 before_filter :find_project
Chris@14 3
Chris@14 4 def issue
Chris@14 5 @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
Chris@14 6 if @issue
Chris@14 7 @attachements = @issue.attachments
Chris@14 8 @description = params[:issue] && params[:issue][:description]
Chris@14 9 if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
Chris@14 10 @description = nil
Chris@14 11 end
Chris@14 12 @notes = params[:notes]
Chris@14 13 else
Chris@14 14 @description = (params[:issue] ? params[:issue][:description] : nil)
Chris@14 15 end
Chris@14 16 render :layout => false
Chris@14 17 end
Chris@14 18
Chris@14 19 private
Chris@14 20
Chris@14 21 def find_project
Chris@14 22 project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
Chris@14 23 @project = Project.find(project_id)
Chris@14 24 rescue ActiveRecord::RecordNotFound
Chris@14 25 render_404
Chris@14 26 end
Chris@14 27
Chris@14 28 end