comparison app/controllers/journals_controller.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
55 (render_404; return false) unless @issue && @detail 55 (render_404; return false) unless @issue && @detail
56 @diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value) 56 @diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value)
57 end 57 end
58 58
59 def new 59 def new
60 journal = Journal.find(params[:journal_id]) if params[:journal_id] 60 @journal = Journal.visible.find(params[:journal_id]) if params[:journal_id]
61 if journal 61 if @journal
62 user = journal.user 62 user = @journal.user
63 text = journal.notes 63 text = @journal.notes
64 else 64 else
65 user = @issue.author 65 user = @issue.author
66 text = @issue.description 66 text = @issue.description
67 end 67 end
68 # Replaces pre blocks with [...] 68 # Replaces pre blocks with [...]
69 text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]') 69 text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
70 content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " 70 @content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
71 content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" 71 @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
72 72 rescue ActiveRecord::RecordNotFound
73 render(:update) { |page| 73 render_404
74 page.<< "$('notes').value = \"#{escape_javascript content}\";"
75 page.show 'update'
76 page << "Form.Element.focus('notes');"
77 page << "Element.scrollTo('update');"
78 page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
79 }
80 end 74 end
81 75
82 def edit 76 def edit
83 (render_403; return false) unless @journal.editable_by?(User.current) 77 (render_403; return false) unless @journal.editable_by?(User.current)
84 if request.post? 78 if request.post?
101 end 95 end
102 96
103 private 97 private
104 98
105 def find_journal 99 def find_journal
106 @journal = Journal.find(params[:id]) 100 @journal = Journal.visible.find(params[:id])
107 @project = @journal.journalized.project 101 @project = @journal.journalized.project
108 rescue ActiveRecord::RecordNotFound 102 rescue ActiveRecord::RecordNotFound
109 render_404 103 render_404
110 end 104 end
111
112 # TODO: duplicated in IssuesController
113 def find_issue
114 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
115 @project = @issue.project
116 rescue ActiveRecord::RecordNotFound
117 render_404
118 end
119 end 105 end