annotate .svn/pristine/5a/5ab7accc1223de2453ac732c58c9aff18698419d.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents dffacf8a6908
children
rev   line source
Chris@1517 1 # Redmine - project management software
Chris@1517 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1517 3 #
Chris@1517 4 # This program is free software; you can redistribute it and/or
Chris@1517 5 # modify it under the terms of the GNU General Public License
Chris@1517 6 # as published by the Free Software Foundation; either version 2
Chris@1517 7 # of the License, or (at your option) any later version.
Chris@1517 8 #
Chris@1517 9 # This program is distributed in the hope that it will be useful,
Chris@1517 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1517 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1517 12 # GNU General Public License for more details.
Chris@1517 13 #
Chris@1517 14 # You should have received a copy of the GNU General Public License
Chris@1517 15 # along with this program; if not, write to the Free Software
Chris@1517 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1517 17
Chris@1517 18 class JournalsController < ApplicationController
Chris@1517 19 before_filter :find_journal, :only => [:edit, :diff]
Chris@1517 20 before_filter :find_issue, :only => [:new]
Chris@1517 21 before_filter :find_optional_project, :only => [:index]
Chris@1517 22 before_filter :authorize, :only => [:new, :edit, :diff]
Chris@1517 23 accept_rss_auth :index
Chris@1517 24 menu_item :issues
Chris@1517 25
Chris@1517 26 helper :issues
Chris@1517 27 helper :custom_fields
Chris@1517 28 helper :queries
Chris@1517 29 include QueriesHelper
Chris@1517 30 helper :sort
Chris@1517 31 include SortHelper
Chris@1517 32
Chris@1517 33 def index
Chris@1517 34 retrieve_query
Chris@1517 35 sort_init 'id', 'desc'
Chris@1517 36 sort_update(@query.sortable_columns)
Chris@1517 37
Chris@1517 38 if @query.valid?
Chris@1517 39 @journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
Chris@1517 40 :limit => 25)
Chris@1517 41 end
Chris@1517 42 @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
Chris@1517 43 render :layout => false, :content_type => 'application/atom+xml'
Chris@1517 44 rescue ActiveRecord::RecordNotFound
Chris@1517 45 render_404
Chris@1517 46 end
Chris@1517 47
Chris@1517 48 def diff
Chris@1517 49 @issue = @journal.issue
Chris@1517 50 if params[:detail_id].present?
Chris@1517 51 @detail = @journal.details.find_by_id(params[:detail_id])
Chris@1517 52 else
Chris@1517 53 @detail = @journal.details.detect {|d| d.prop_key == 'description'}
Chris@1517 54 end
Chris@1517 55 (render_404; return false) unless @issue && @detail
Chris@1517 56 @diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value)
Chris@1517 57 end
Chris@1517 58
Chris@1517 59 def new
Chris@1517 60 @journal = Journal.visible.find(params[:journal_id]) if params[:journal_id]
Chris@1517 61 if @journal
Chris@1517 62 user = @journal.user
Chris@1517 63 text = @journal.notes
Chris@1517 64 else
Chris@1517 65 user = @issue.author
Chris@1517 66 text = @issue.description
Chris@1517 67 end
Chris@1517 68 # Replaces pre blocks with [...]
Chris@1517 69 text = text.to_s.strip.gsub(%r{<pre>(.*?)</pre>}m, '[...]')
Chris@1517 70 @content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
Chris@1517 71 @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
Chris@1517 72 rescue ActiveRecord::RecordNotFound
Chris@1517 73 render_404
Chris@1517 74 end
Chris@1517 75
Chris@1517 76 def edit
Chris@1517 77 (render_403; return false) unless @journal.editable_by?(User.current)
Chris@1517 78 if request.post?
Chris@1517 79 @journal.update_attributes(:notes => params[:notes]) if params[:notes]
Chris@1517 80 @journal.destroy if @journal.details.empty? && @journal.notes.blank?
Chris@1517 81 call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params})
Chris@1517 82 respond_to do |format|
Chris@1517 83 format.html { redirect_to issue_path(@journal.journalized) }
Chris@1517 84 format.js { render :action => 'update' }
Chris@1517 85 end
Chris@1517 86 else
Chris@1517 87 respond_to do |format|
Chris@1517 88 format.html {
Chris@1517 89 # TODO: implement non-JS journal update
Chris@1517 90 render :nothing => true
Chris@1517 91 }
Chris@1517 92 format.js
Chris@1517 93 end
Chris@1517 94 end
Chris@1517 95 end
Chris@1517 96
Chris@1517 97 private
Chris@1517 98
Chris@1517 99 def find_journal
Chris@1517 100 @journal = Journal.visible.find(params[:id])
Chris@1517 101 @project = @journal.journalized.project
Chris@1517 102 rescue ActiveRecord::RecordNotFound
Chris@1517 103 render_404
Chris@1517 104 end
Chris@1517 105 end