Revision 1298:4f746d8966dd app/controllers

View differences:

app/controllers/account_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
25 25
  # Login request and validation
26 26
  def login
27 27
    if request.get?
28
      logout_user
28
      if User.current.logged?
29
        redirect_to home_url
30
      end
29 31
    else
30 32
      authenticate_user
31 33
    end
......
36 38

  
37 39
  # Log out current user and redirect to welcome page
38 40
  def logout
39
    logout_user
40
    redirect_to home_url
41
    if User.current.anonymous?
42
      redirect_to home_url
43
    elsif request.post?
44
      logout_user
45
      redirect_to home_url
46
    end
47
    # display the logout form
41 48
  end
42 49

  
43 50
  # Lets user choose a new password
44 51
  def lost_password
45
    redirect_to(home_url) && return unless Setting.lost_password?
52
    (redirect_to(home_url); return) unless Setting.lost_password?
46 53
    if params[:token]
47
      @token = Token.find_by_action_and_value("recovery", params[:token].to_s)
54
      @token = Token.find_token("recovery", params[:token].to_s)
48 55
      if @token.nil? || @token.expired?
49 56
        redirect_to home_url
50 57
        return
......
92 99

  
93 100
  # User self-registration
94 101
  def register
95
    redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration]
102
    (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
96 103

  
97 104
    if request.get?
98 105
      session[:auth_source_registration] = nil
99
      @user = User.new(:language => Setting.default_language)
106
      @user = User.new(:language => current_language.to_s)
100 107

  
101 108
      @ssamr_user_details = SsamrUserDetail.new
102 109

  
......
116 123
          session[:auth_source_registration] = nil
117 124
          self.logged_user = @user
118 125
          flash[:notice] = l(:notice_account_activated)
119
          redirect_to :controller => 'my', :action => 'account'
126
          redirect_to my_account_path
120 127
        end
121 128
      else
122 129
        @user.login = params[:user][:login]
......
145 152

  
146 153
  # Token based account activation
147 154
  def activate
148
    redirect_to(home_url) && return unless Setting.self_registration? && params[:token]
149
    token = Token.find_by_action_and_value('register', params[:token])
150
    redirect_to(home_url) && return unless token and !token.expired?
155
    (redirect_to(home_url); return) unless Setting.self_registration? && params[:token].present?
156
    token = Token.find_token('register', params[:token].to_s)
157
    (redirect_to(home_url); return) unless token and !token.expired?
151 158
    user = token.user
152
    redirect_to(home_url) && return unless user.registered?
159
    (redirect_to(home_url); return) unless user.registered?
153 160
    user.activate
154 161
    if user.save
155 162
      token.destroy
......
182 189
  end
183 190

  
184 191
  def open_id_authenticate(openid_url)
185
    authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url, :method => :post) do |result, identity_url, registration|
192
    back_url = signin_url(:autologin => params[:autologin])
193

  
194
    authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => back_url, :method => :post) do |result, identity_url, registration|
186 195
      if result.successful?
187 196
        user = User.find_or_initialize_by_identity_url(identity_url)
188 197
        if user.new_record?
189 198
          # Self-registration off
190
          redirect_to(home_url) && return unless Setting.self_registration?
199
          (redirect_to(home_url); return) unless Setting.self_registration?
191 200

  
192 201
          # Create on the fly
193 202
          user.login = registration['nickname'] unless registration['nickname'].nil?
......
231 240
      set_autologin_cookie(user)
232 241
    end
233 242
    call_hook(:controller_account_success_authentication_after, {:user => user })
234
    redirect_back_or_default :controller => 'my', :action => 'page'
243
    redirect_back_or_default my_page_path
235 244
  end
236 245

  
237 246
  def set_autologin_cookie(user)
238 247
    token = Token.create(:user => user, :action => 'autologin')
239
    cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
240 248
    cookie_options = {
241 249
      :value => token.value,
242 250
      :expires => 1.year.from_now,
......
244 252
      :secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
245 253
      :httponly => true
246 254
    }
247
    cookies[cookie_name] = cookie_options
255
    cookies[autologin_cookie_name] = cookie_options
248 256
  end
249 257

  
250 258
  # Onthefly creation failed, display the registration form to fill/fix attributes
......
283 291
    if user.save
284 292
      self.logged_user = user
285 293
      flash[:notice] = l(:notice_account_activated)
286
      redirect_to :controller => 'my', :action => 'account'
294
      redirect_to my_account_path
287 295
    else
288 296
      yield if block_given?
289 297
    end
app/controllers/activities_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
app/controllers/admin_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
23 23

  
24 24
  before_filter :require_admin
25 25
  helper :sort
26
  include SortHelper	
26
  include SortHelper
27 27

  
28 28
  def index
29 29
    @no_configuration_data = Redmine::DefaultData::Loader::no_data?
30 30
  end
31
	
31

  
32 32
  def projects
33 33
    @status = params[:status] || 1
34 34

  
35
    scope = Project.status(@status)
35
    scope = Project.status(@status).order('lft')
36 36
    scope = scope.like(params[:name]) if params[:name].present?
37

  
38
    @projects = scope.all(:order => 'lft')
37
    @projects = scope.all
39 38

  
40 39
    render :action => "projects", :layout => false if request.xhr?
41 40
  end
......
55 54
        flash[:error] = l(:error_can_t_load_default_data, e.message)
56 55
      end
57 56
    end
58
    redirect_to :action => 'index'
57
    redirect_to admin_path
59 58
  end
60 59

  
61 60
  def test_email
......
69 68
      flash[:error] = l(:notice_email_error, e.message)
70 69
    end
71 70
    ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
72
    redirect_to :controller => 'settings', :action => 'edit', :tab => 'notifications'
71
    redirect_to settings_path(:tab => 'notifications')
73 72
  end
74 73

  
75 74
  def info
app/controllers/application_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
22 22

  
23 23
class ApplicationController < ActionController::Base
24 24
  include Redmine::I18n
25
  include Redmine::Pagination
26
  include RoutesHelper
27
  helper :routes
25 28

  
26 29
  class_attribute :accept_api_auth_actions
27 30
  class_attribute :accept_rss_auth_actions
......
32 35
  protect_from_forgery
33 36
  def handle_unverified_request
34 37
    super
35
    cookies.delete(:autologin)
38
    cookies.delete(autologin_cookie_name)
36 39
  end
37 40

  
38 41
  before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
......
124 127
    user
125 128
  end
126 129

  
130
  def autologin_cookie_name
131
    Redmine::Configuration['autologin_cookie_name'].presence || 'autologin'
132
  end
133

  
127 134
  def try_to_autologin
128
    if cookies[:autologin] && Setting.autologin?
135
    if cookies[autologin_cookie_name] && Setting.autologin?
129 136
      # auto-login feature starts a new session
130
      user = User.try_to_autologin(cookies[:autologin])
137
      user = User.try_to_autologin(cookies[autologin_cookie_name])
131 138
      if user
132 139
        reset_session
133 140
        start_user_session(user)
......
150 157
  # Logs out current user
151 158
  def logout_user
152 159
    if User.current.logged?
153
      cookies.delete :autologin
160
      cookies.delete(autologin_cookie_name)
154 161
      Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
155 162
      self.logged_user = nil
156 163
    end
......
300 307
    render_404
301 308
  end
302 309

  
310
  def find_attachments
311
    if (attachments = params[:attachments]).present?
312
      att = attachments.values.collect do |attachment|
313
        Attachment.find_by_token( attachment[:token] ) if attachment[:token].present?
314
      end
315
      att.compact!
316
    end
317
    @attachments = att || []
318
  end
319

  
303 320
  # make sure that the user is a member of the project (or admin) if project is private
304 321
  # used as a before_filter for actions that do not require any particular permission on the project
305 322
  def check_project_privacy
app/controllers/attachments_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
91 91
    @attachment = Attachment.new(:file => request.raw_post)
92 92
    @attachment.author = User.current
93 93
    @attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
94
    saved = @attachment.save
94 95

  
95
    if @attachment.save
96
      respond_to do |format|
97
        format.api { render :action => 'upload', :status => :created }
98
      end
99
    else
100
      respond_to do |format|
101
        format.api { render_validation_errors(@attachment) }
102
      end
96
    respond_to do |format|
97
      format.js
98
      format.api {
99
        if saved
100
          render :action => 'upload', :status => :created
101
        else
102
          render_validation_errors(@attachment)
103
        end
104
      }
103 105
    end
104 106
  end
105 107

  
......
107 109
    if @attachment.container.respond_to?(:init_journal)
108 110
      @attachment.container.init_journal(User.current)
109 111
    end
110
    # Make sure association callbacks are called
111
    @attachment.container.attachments.delete(@attachment)
112
    redirect_to_referer_or project_path(@project)
112
    if @attachment.container
113
      # Make sure association callbacks are called
114
      @attachment.container.attachments.delete(@attachment)
115
    else
116
      @attachment.destroy
117
    end
118

  
119
    respond_to do |format|
120
      format.html { redirect_to_referer_or project_path(@project) }
121
      format.js
122
    end
113 123
  end
114 124

  
115 125
  def toggle_active
......
132 142

  
133 143
  # Checks that the file exists and is readable
134 144
  def file_readable
135
    @attachment.readable? ? true : render_404
145
    if @attachment.readable?
146
      true
147
    else
148
      logger.error "Cannot send attachment, #{@attachment.diskfile} does not exist or is unreadable."
149
      render_404
150
    end
136 151
  end
137 152

  
138 153
  def read_authorize
app/controllers/auth_sources_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
20 20
  menu_item :ldap_authentication
21 21

  
22 22
  before_filter :require_admin
23
  before_filter :find_auth_source, :only => [:edit, :update, :test_connection, :destroy]
23 24

  
24 25
  def index
25
    @auth_source_pages, @auth_sources = paginate AuthSource, :per_page => 10
26
    @auth_source_pages, @auth_sources = paginate AuthSource, :per_page => 25
26 27
  end
27 28

  
28 29
  def new
29 30
    klass_name = params[:type] || 'AuthSourceLdap'
30 31
    @auth_source = AuthSource.new_subclass_instance(klass_name, params[:auth_source])
32
    render_404 unless @auth_source
31 33
  end
32 34

  
33 35
  def create
34 36
    @auth_source = AuthSource.new_subclass_instance(params[:type], params[:auth_source])
35 37
    if @auth_source.save
36 38
      flash[:notice] = l(:notice_successful_create)
37
      redirect_to :action => 'index'
39
      redirect_to auth_sources_path
38 40
    else
39 41
      render :action => 'new'
40 42
    end
41 43
  end
42 44

  
43 45
  def edit
44
    @auth_source = AuthSource.find(params[:id])
45 46
  end
46 47

  
47 48
  def update
48
    @auth_source = AuthSource.find(params[:id])
49 49
    if @auth_source.update_attributes(params[:auth_source])
50 50
      flash[:notice] = l(:notice_successful_update)
51
      redirect_to :action => 'index'
51
      redirect_to auth_sources_path
52 52
    else
53 53
      render :action => 'edit'
54 54
    end
55 55
  end
56 56

  
57 57
  def test_connection
58
    @auth_source = AuthSource.find(params[:id])
59 58
    begin
60 59
      @auth_source.test_connection
61 60
      flash[:notice] = l(:notice_successful_connection)
62 61
    rescue Exception => e
63 62
      flash[:error] = l(:error_unable_to_connect, e.message)
64 63
    end
65
    redirect_to :action => 'index'
64
    redirect_to auth_sources_path
66 65
  end
67 66

  
68 67
  def destroy
69
    @auth_source = AuthSource.find(params[:id])
70
    unless @auth_source.users.find(:first)
68
    unless @auth_source.users.exists?
71 69
      @auth_source.destroy
72 70
      flash[:notice] = l(:notice_successful_delete)
73 71
    end
74
    redirect_to :action => 'index'
72
    redirect_to auth_sources_path
73
  end
74

  
75
  def autocomplete_for_new_user
76
    results = AuthSource.search(params[:term])
77

  
78
    render :json => results.map {|result| {
79
      'value' => result[:login],
80
      'label' => "#{result[:login]} (#{result[:firstname]} #{result[:lastname]})",
81
      'login' => result[:login].to_s,
82
      'firstname' => result[:firstname].to_s,
83
      'lastname' => result[:lastname].to_s,
84
      'mail' => result[:mail].to_s,
85
      'auth_source_id' => result[:auth_source_id].to_s
86
    }}
87
  end
88

  
89
  private
90

  
91
  def find_auth_source
92
    @auth_source = AuthSource.find(params[:id])
93
  rescue ActiveRecord::RecordNotFound
94
    render_404
75 95
  end
76 96
end
app/controllers/auto_completes_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
23 23
    q = (params[:q] || params[:term]).to_s.strip
24 24
    if q.present?
25 25
      scope = (params[:scope] == "all" || @project.nil? ? Issue : @project.issues).visible
26
      if q.match(/^\d+$/)
27
        @issues << scope.find_by_id(q.to_i)
26
      if q.match(/\A#?(\d+)\z/)
27
        @issues << scope.find_by_id($1.to_i)
28 28
      end
29
      @issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%").order("#{Issue.table_name}.id DESC").limit(10).all
29
      @issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE LOWER(?)", "%#{q}%").order("#{Issue.table_name}.id DESC").limit(10).all
30 30
      @issues.compact!
31 31
    end
32 32
    render :layout => false
app/controllers/boards_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
37 37
    respond_to do |format|
38 38
      format.html {
39 39
        sort_init 'updated_on', 'desc'
40
        sort_update	'created_on' => "#{Message.table_name}.created_on",
40
        sort_update 'created_on' => "#{Message.table_name}.created_on",
41 41
                    'replies' => "#{Message.table_name}.replies_count",
42 42
                    'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
43 43

  
44 44
        @topic_count = @board.topics.count
45
        @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
45
        @topic_pages = Paginator.new @topic_count, per_page_option, params['page']
46 46
        @topics =  @board.topics.
47 47
          reorder("#{Message.table_name}.sticky DESC").
48 48
          includes(:last_reply).
49
          limit(@topic_pages.items_per_page).
50
          offset(@topic_pages.current.offset).
49
          limit(@topic_pages.per_page).
50
          offset(@topic_pages.offset).
51 51
          order(sort_clause).
52 52
          preload(:author, {:last_reply => :author}).
53 53
          all
......
55 55
        render :action => 'show', :layout => !request.xhr?
56 56
      }
57 57
      format.atom {
58
        @messages = @board.messages.find :all, :order => 'created_on DESC',
59
                                               :include => [:author, :board],
60
                                               :limit => Setting.feeds_limit.to_i
58
        @messages = @board.messages.
59
          reorder('created_on DESC').
60
          includes(:author, :board).
61
          limit(Setting.feeds_limit.to_i).
62
          all
61 63
        render_feed(@messages, :title => "#{@project}: #{@board}")
62 64
      }
63 65
    end
......
98 100

  
99 101
private
100 102
  def redirect_to_settings_in_projects
101
    redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
103
    redirect_to settings_project_path(@project, :tab => 'boards')
102 104
  end
103 105

  
104 106
  def find_board_if_available
app/controllers/calendars_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
app/controllers/comments_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
32 32
      flash[:notice] = l(:label_comment_added)
33 33
    end
34 34

  
35
    redirect_to :controller => 'news', :action => 'show', :id => @news
35
    redirect_to news_path(@news)
36 36
  end
37 37

  
38 38
  def destroy
39 39
    @news.comments.find(params[:comment_id]).destroy
40
    redirect_to :controller => 'news', :action => 'show', :id => @news
40
    redirect_to news_path(@news)
41 41
  end
42 42

  
43 43
  private
app/controllers/context_menus_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
21 21

  
22 22
  def issues
23 23
    @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
24
    (render_404; return) unless @issues.present?
24 25
    if (@issues.size == 1)
25 26
      @issue = @issues.first
26 27
    end
......
74 75
  def time_entries
75 76
    @time_entries = TimeEntry.all(
76 77
       :conditions => {:id => params[:ids]}, :include => :project)
78
    (render_404; return) unless @time_entries.present?
79

  
77 80
    @projects = @time_entries.collect(&:project).compact.uniq
78 81
    @project = @projects.first if @projects.size == 1
79 82
    @activities = TimeEntryActivity.shared.active
app/controllers/custom_fields_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
23 23
  before_filter :find_custom_field, :only => [:edit, :update, :destroy]
24 24

  
25 25
  def index
26
    @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
26
    @custom_fields_by_type = CustomField.all.group_by {|f| f.class.name }
27 27
    @tab = params[:tab] || 'IssueCustomField'
28 28
  end
29 29

  
......
31 31
  end
32 32

  
33 33
  def create
34
    if request.post? and @custom_field.save
34
    if @custom_field.save
35 35
      flash[:notice] = l(:notice_successful_create)
36 36
      call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
37
      redirect_to :action => 'index', :tab => @custom_field.class.name
37
      redirect_to custom_fields_path(:tab => @custom_field.class.name)
38 38
    else
39 39
      render :action => 'new'
40 40
    end
......
44 44
  end
45 45

  
46 46
  def update
47
    if request.put? and @custom_field.update_attributes(params[:custom_field])
47
    if @custom_field.update_attributes(params[:custom_field])
48 48
      flash[:notice] = l(:notice_successful_update)
49 49
      call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field)
50
      redirect_to :action => 'index', :tab => @custom_field.class.name
50
      redirect_to custom_fields_path(:tab => @custom_field.class.name)
51 51
    else
52 52
      render :action => 'edit'
53 53
    end
54 54
  end
55 55

  
56 56
  def destroy
57
    @custom_field.destroy
58
    redirect_to :action => 'index', :tab => @custom_field.class.name
59
  rescue
60
    flash[:error] = l(:error_can_not_delete_custom_field)
61
    redirect_to :action => 'index'
57
    begin
58
      @custom_field.destroy
59
    rescue
60
      flash[:error] = l(:error_can_not_delete_custom_field)
61
    end
62
    redirect_to custom_fields_path(:tab => @custom_field.class.name)
62 63
  end
63 64

  
64 65
  private
......
67 68
    @custom_field = CustomField.new_subclass_instance(params[:type], params[:custom_field])
68 69
    if @custom_field.nil?
69 70
      render_404
71
    else
72
      @custom_field.default_value = nil
70 73
    end
71 74
  end
72 75

  
app/controllers/documents_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
27 27

  
28 28
  def index
29 29
    @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
30
    documents = @project.documents.find :all, :include => [:attachments, :category]
30
    documents = @project.documents.includes(:attachments, :category).all
31 31
    case @sort_by
32 32
    when 'date'
33 33
      @grouped = documents.group_by {|d| d.updated_on.to_date }
......
43 43
  end
44 44

  
45 45
  def show
46
    @attachments = @document.attachments.find(:all, :order => "created_on DESC")
46
    @attachments = @document.attachments.all
47 47
  end
48 48

  
49 49
  def new
......
58 58
    if @document.save
59 59
      render_attachment_warning_if_needed(@document)
60 60
      flash[:notice] = l(:notice_successful_create)
61
      redirect_to :action => 'index', :project_id => @project
61
      redirect_to project_documents_path(@project)
62 62
    else
63 63
      render :action => 'new'
64 64
    end
......
71 71
    @document.safe_attributes = params[:document]
72 72
    if request.put? and @document.save
73 73
      flash[:notice] = l(:notice_successful_update)
74
      redirect_to :action => 'show', :id => @document
74
      redirect_to document_path(@document)
75 75
    else
76 76
      render :action => 'edit'
77 77
    end
......
79 79

  
80 80
  def destroy
81 81
    @document.destroy if request.delete?
82
    redirect_to :controller => 'documents', :action => 'index', :project_id => @project
82
    redirect_to project_documents_path(@project)
83 83
  end
84 84

  
85 85
  def add_attachment
......
89 89
    if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
90 90
      Mailer.attachments_added(attachments[:files]).deliver
91 91
    end
92
    redirect_to :action => 'show', :id => @document
92
    redirect_to document_path(@document)
93 93
  end
94 94
end
app/controllers/enumerations_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
46 46
  def create
47 47
    if request.post? && @enumeration.save
48 48
      flash[:notice] = l(:notice_successful_create)
49
      redirect_to :action => 'index'
49
      redirect_to enumerations_path
50 50
    else
51 51
      render :action => 'new'
52 52
    end
......
58 58
  def update
59 59
    if request.put? && @enumeration.update_attributes(params[:enumeration])
60 60
      flash[:notice] = l(:notice_successful_update)
61
      redirect_to :action => 'index'
61
      redirect_to enumerations_path
62 62
    else
63 63
      render :action => 'edit'
64 64
    end
......
68 68
    if !@enumeration.in_use?
69 69
      # No associated objects
70 70
      @enumeration.destroy
71
      redirect_to :action => 'index'
71
      redirect_to enumerations_path
72 72
      return
73 73
    elsif params[:reassign_to_id]
74 74
      if reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id])
75 75
        @enumeration.destroy(reassign_to)
76
        redirect_to :action => 'index'
76
        redirect_to enumerations_path
77 77
        return
78 78
      end
79 79
    end
80
    @enumerations = @enumeration.class.all - [@enumeration]
80
    @enumerations = @enumeration.class.system.all - [@enumeration]
81 81
  end
82 82

  
83 83
  private
app/controllers/files_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
32 32
                'size' => "#{Attachment.table_name}.filesize",
33 33
                'downloads' => "#{Attachment.table_name}.downloads"
34 34

  
35
    @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
36
    @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
35
    @containers = [ Project.includes(:attachments).reorder(sort_clause).find(@project.id)]
36
    @containers += @project.versions.includes(:attachments).reorder(sort_clause).all.sort.reverse
37 37
    render :layout => !request.xhr?
38 38
  end
39 39

  
app/controllers/gantts_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
app/controllers/groups_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
84 84
    @group.destroy
85 85

  
86 86
    respond_to do |format|
87
      format.html { redirect_to(groups_url) }
87
      format.html { redirect_to(groups_path) }
88 88
      format.api  { render_api_ok }
89 89
    end
90 90
  end
......
93 93
    @users = User.find_all_by_id(params[:user_id] || params[:user_ids])
94 94
    @group.users << @users if request.post?
95 95
    respond_to do |format|
96
      format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
96
      format.html { redirect_to edit_group_path(@group, :tab => 'users') }
97 97
      format.js
98 98
      format.api { render_api_ok }
99 99
    end
......
102 102
  def remove_user
103 103
    @group.users.delete(User.find(params[:user_id])) if request.delete?
104 104
    respond_to do |format|
105
      format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
105
      format.html { redirect_to edit_group_path(@group, :tab => 'users') }
106 106
      format.js
107 107
      format.api { render_api_ok }
108 108
    end
109 109
  end
110 110

  
111 111
  def autocomplete_for_user
112
    @users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
113
    render :layout => false
112
    respond_to do |format|
113
      format.js
114
    end
114 115
  end
115 116

  
116 117
  def edit_membership
117 118
    @membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
118 119
    @membership.save if request.post?
119 120
    respond_to do |format|
120
      format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
121
      format.html { redirect_to edit_group_path(@group, :tab => 'memberships') }
121 122
      format.js
122 123
    end
123 124
  end
......
125 126
  def destroy_membership
126 127
    Member.find(params[:membership_id]).destroy if request.post?
127 128
    respond_to do |format|
128
      format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
129
      format.html { redirect_to edit_group_path(@group, :tab => 'memberships') }
129 130
      format.js
130 131
    end
131 132
  end
app/controllers/issue_categories_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
26 26

  
27 27
  def index
28 28
    respond_to do |format|
29
      format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project }
29
      format.html { redirect_to_settings_in_projects }
30 30
      format.api { @categories = @project.issue_categories.all }
31 31
    end
32 32
  end
33 33

  
34 34
  def show
35 35
    respond_to do |format|
36
      format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project }
36
      format.html { redirect_to_settings_in_projects }
37 37
      format.api
38 38
    end
39 39
  end
......
55 55
      respond_to do |format|
56 56
        format.html do
57 57
          flash[:notice] = l(:notice_successful_create)
58
          redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
58
          redirect_to_settings_in_projects
59 59
        end
60 60
        format.js
61 61
        format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
......
78 78
      respond_to do |format|
79 79
        format.html {
80 80
          flash[:notice] = l(:notice_successful_update)
81
          redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
81
          redirect_to_settings_in_projects
82 82
        }
83 83
        format.api { render_api_ok }
84 84
      end
......
99 99
      end
100 100
      @category.destroy(reassign_to)
101 101
      respond_to do |format|
102
        format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' }
102
        format.html { redirect_to_settings_in_projects }
103 103
        format.api { render_api_ok }
104 104
      end
105 105
      return
......
107 107
    @categories = @project.issue_categories - [@category]
108 108
  end
109 109

  
110
private
110
  private
111

  
112
  def redirect_to_settings_in_projects
113
    redirect_to settings_project_path(@project, :tab => 'categories')
114
  end
115

  
111 116
  # Wrap ApplicationController's find_model_object method to set
112 117
  # @category instead of just @issue_category
113 118
  def find_model_object
app/controllers/issue_relations_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
48 48
    saved = @relation.save
49 49

  
50 50
    respond_to do |format|
51
      format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
51
      format.html { redirect_to issue_path(@issue) }
52 52
      format.js {
53
        @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
53
        @relations = @issue.reload.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
54 54
      }
55 55
      format.api {
56 56
        if saved
......
67 67
    @relation.destroy
68 68

  
69 69
    respond_to do |format|
70
      format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to?
70
      format.html { redirect_to issue_path(@relation.issue_from) }
71 71
      format.js
72 72
      format.api  { render_api_ok }
73 73
    end
app/controllers/issue_statuses_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
25 25
  def index
26 26
    respond_to do |format|
27 27
      format.html {
28
        @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
28
        @issue_status_pages, @issue_statuses = paginate IssueStatus.sorted, :per_page => 25
29 29
        render :action => "index", :layout => false if request.xhr?
30 30
      }
31 31
      format.api {
......
42 42
    @issue_status = IssueStatus.new(params[:issue_status])
43 43
    if request.post? && @issue_status.save
44 44
      flash[:notice] = l(:notice_successful_create)
45
      redirect_to :action => 'index'
45
      redirect_to issue_statuses_path
46 46
    else
47 47
      render :action => 'new'
48 48
    end
......
56 56
    @issue_status = IssueStatus.find(params[:id])
57 57
    if request.put? && @issue_status.update_attributes(params[:issue_status])
58 58
      flash[:notice] = l(:notice_successful_update)
59
      redirect_to :action => 'index'
59
      redirect_to issue_statuses_path
60 60
    else
61 61
      render :action => 'edit'
62 62
    end
......
64 64

  
65 65
  def destroy
66 66
    IssueStatus.find(params[:id]).destroy
67
    redirect_to :action => 'index'
67
    redirect_to issue_statuses_path
68 68
  rescue
69 69
    flash[:error] = l(:error_unable_delete_issue_status)
70
    redirect_to :action => 'index'
71
  end  	
70
    redirect_to issue_statuses_path
71
  end
72 72

  
73 73
  def update_issue_done_ratio
74 74
    if request.post? && IssueStatus.update_issue_done_ratios
......
76 76
    else
77 77
      flash[:error] =  l(:error_issue_done_ratios_not_updated)
78 78
    end
79
    redirect_to :action => 'index'
79
    redirect_to issue_statuses_path
80 80
  end
81 81
end
app/controllers/issues_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
21 21

  
22 22
  before_filter :find_issue, :only => [:show, :edit, :update]
23 23
  before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
24
  before_filter :find_project, :only => [:new, :create]
24
  before_filter :find_project, :only => [:new, :create, :update_form]
25 25
  before_filter :authorize, :except => [:index]
26 26
  before_filter :find_optional_project, :only => [:index]
27 27
  before_filter :check_for_default_issue_status, :only => [:new, :create]
28
  before_filter :build_new_issue_from_params, :only => [:new, :create]
28
  before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form]
29 29
  accept_rss_auth :index, :show
30 30
  accept_api_auth :index, :show, :create, :update, :destroy
31 31

  
......
71 71
      end
72 72

  
73 73
      @issue_count = @query.issue_count
74
      @issue_pages = Paginator.new self, @issue_count, @limit, params['page']
75
      @offset ||= @issue_pages.current.offset
74
      @issue_pages = Paginator.new @issue_count, @limit, params['page']
75
      @offset ||= @issue_pages.offset
76 76
      @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
77 77
                              :order => sort_clause,
78 78
                              :offset => @offset,
......
85 85
          Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
86 86
        }
87 87
        format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
88
        format.csv  { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') }
89
        format.pdf  { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
88
        format.csv  { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => 'issues.csv') }
89
        format.pdf  { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'issues.pdf') }
90 90
      end
91 91
    else
92 92
      respond_to do |format|
......
132 132
  def new
133 133
    respond_to do |format|
134 134
      format.html { render :action => 'new', :layout => !request.xhr? }
135
      format.js { render :partial => 'update_form' }
136 135
    end
137 136
  end
138 137

  
......
154 153
        format.html {
155 154
          render_attachment_warning_if_needed(@issue)
156 155
          flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
157
          redirect_to(params[:continue] ?  { :action => 'new', :project_id => @issue.project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
158
                      { :action => 'show', :id => @issue })
156
          if params[:continue]
157
            attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
158
            redirect_to new_project_issue_path(@issue.project, :issue => attrs)
159
          else
160
            redirect_to issue_path(@issue)
161
          end
159 162
        }
160 163
        format.api  { render :action => 'show', :status => :created, :location => issue_url(@issue) }
161 164
      end
......
196 199
      flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
197 200

  
198 201
      respond_to do |format|
199
        format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
202
        format.html { redirect_back_or_default issue_path(@issue) }
200 203
        format.api  { render_api_ok }
201 204
      end
202 205
    else
......
207 210
    end
208 211
  end
209 212

  
213
  # Updates the issue form when changing the project, status or tracker
214
  # on issue creation/update
215
  def update_form
216
  end
217

  
210 218
  # Bulk edit/copy a set of issues
211 219
  def bulk_edit
212 220
    @issues.sort!
......
279 287

  
280 288
    if params[:follow]
281 289
      if @issues.size == 1 && moved_issues.size == 1
282
        redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
290
        redirect_to issue_path(moved_issues.first)
283 291
      elsif moved_issues.map(&:project).uniq.size == 1
284
        redirect_to :controller => 'issues', :action => 'index', :project_id => moved_issues.map(&:project).first
292
        redirect_to project_issues_path(moved_issues.map(&:project).first)
285 293
      end
286 294
    else
287
      redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
295
      redirect_back_or_default _project_issues_path(@project)
288 296
    end
289 297
  end
290 298

  
......
317 325
      end
318 326
    end
319 327
    respond_to do |format|
320
      format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
328
      format.html { redirect_back_or_default _project_issues_path(@project) }
321 329
      format.api  { render_api_ok }
322 330
    end
323 331
  end
app/controllers/journals_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
80 80
      @journal.destroy if @journal.details.empty? && @journal.notes.blank?
81 81
      call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params})
82 82
      respond_to do |format|
83
        format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id }
83
        format.html { redirect_to issue_path(@journal.journalized) }
84 84
        format.js { render :action => 'update' }
85 85
      end
86 86
    else
app/controllers/mail_handler_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
app/controllers/members_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
32 32
      format.api {
33 33
        @offset, @limit = api_offset_and_limit
34 34
        @member_count = @project.member_principals.count
35
        @member_pages = Paginator.new self, @member_count, @limit, params['page']
36
        @offset ||= @member_pages.current.offset
35
    @member_pages = Paginator.new @member_count, @limit, params['page']
36
    @offset ||= @member_pages.offset
37 37
        @members =  @project.member_principals.all(
38 38
          :order => "#{Member.table_name}.id",
39 39
          :limit  =>  @limit,
app/controllers/messages_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
19 19
  menu_item :boards
20 20
  default_search_scope :messages
21 21
  before_filter :find_board, :only => [:new, :preview]
22
  before_filter :find_attachments, :only => [:preview]
22 23
  before_filter :find_message, :except => [:new, :preview]
23 24
  before_filter :authorize, :except => [:preview, :edit, :destroy]
24 25

  
......
39 40
    end
40 41

  
41 42
    @reply_count = @topic.children.count
42
    @reply_pages = Paginator.new self, @reply_count, REPLIES_PER_PAGE, page
43
    @replies =  @topic.children.find(:all, :include => [:author, :attachments, {:board => :project}],
44
                                           :order => "#{Message.table_name}.created_on ASC",
45
                                           :limit => @reply_pages.items_per_page,
46
                                           :offset => @reply_pages.current.offset)
43
    @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
44
    @replies =  @topic.children.
45
      includes(:author, :attachments, {:board => :project}).
46
      reorder("#{Message.table_name}.created_on ASC").
47
      limit(@reply_pages.per_page).
48
      offset(@reply_pages.offset).
49
      all
47 50

  
48 51
    @reply = Message.new(:subject => "RE: #{@message.subject}")
49 52
    render :action => "show", :layout => false if request.xhr?
......
115 118

  
116 119
  def preview
117 120
    message = @board.messages.find_by_id(params[:id])
118
    @attachements = message.attachments if message
119 121
    @text = (params[:message] || params[:reply])[:content]
120 122
    @previewed = message
121 123
    render :partial => 'common/preview'
app/controllers/my_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
94 94
        @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
95 95
        set_language_if_valid @user.language
96 96
        flash[:notice] = l(:notice_account_updated)
97
        redirect_to :action => 'account'
97
        redirect_to my_account_path
98 98
        return
99 99
      end
100 100
    end
......
104 104
  def destroy
105 105
    @user = User.current
106 106
    unless @user.own_account_deletable?
107
      redirect_to :action => 'account'
107
      redirect_to my_account_path
108 108
      return
109 109
    end
110 110

  
......
123 123
    @user = User.current
124 124
    unless @user.change_password_allowed?
125 125
      flash[:error] = l(:notice_can_t_change_password)
126
      redirect_to :action => 'account'
126
      redirect_to my_account_path
127 127
      return
128 128
    end
129 129
    if request.post?
......
131 131
        @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
132 132
        if @user.save
133 133
          flash[:notice] = l(:notice_account_password_updated)
134
          redirect_to :action => 'account'
134
          redirect_to my_account_path
135 135
        end
136 136
      else
137 137
        flash[:error] = l(:notice_account_wrong_password)
......
149 149
      User.current.rss_key
150 150
      flash[:notice] = l(:notice_feeds_access_key_reseted)
151 151
    end
152
    redirect_to :action => 'account'
152
    redirect_to my_account_path
153 153
  end
154 154

  
155 155
  # Create a new API key
......
162 162
      User.current.api_key
163 163
      flash[:notice] = l(:notice_api_access_key_reseted)
164 164
    end
165
    redirect_to :action => 'account'
165
    redirect_to my_account_path
166 166
  end
167 167

  
168 168
  # User's page layout configuration
......
192 192
      @user.pref[:my_page_layout] = layout
193 193
      @user.pref.save
194 194
    end
195
    redirect_to :action => 'page_layout'
195
    redirect_to my_page_layout_path
196 196
  end
197 197

  
198 198
  # Remove a block to user's page
......
205 205
    %w(top left right).each {|f| (layout[f] ||= []).delete block }
206 206
    @user.pref[:my_page_layout] = layout
207 207
    @user.pref.save
208
    redirect_to :action => 'page_layout'
208
    redirect_to my_page_layout_path
209 209
  end
210 210

  
211 211
  # Change blocks order on user's page
app/controllers/news_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
40 40
    scope = @project ? @project.news.visible : News.visible
41 41

  
42 42
    @news_count = scope.count
43
    @news_pages = Paginator.new self, @news_count, @limit, params['page']
44
    @offset ||= @news_pages.current.offset
43
    @news_pages = Paginator.new @news_count, @limit, params['page']
44
    @offset ||= @news_pages.offset
45 45
    @newss = scope.all(:include => [:author, :project],
46 46
                                       :order => "#{News.table_name}.created_on DESC",
47 47
                                       :offset => @offset,
......
73 73
    if @news.save
74 74
      render_attachment_warning_if_needed(@news)
75 75
      flash[:notice] = l(:notice_successful_create)
76
      redirect_to :controller => 'news', :action => 'index', :project_id => @project
76
      redirect_to project_news_index_path(@project)
77 77
    else
78 78
      render :action => 'new'
79 79
    end
......
88 88
    if @news.save
89 89
      render_attachment_warning_if_needed(@news)
90 90
      flash[:notice] = l(:notice_successful_update)
91
      redirect_to :action => 'show', :id => @news
91
      redirect_to news_path(@news)
92 92
    else
93 93
      render :action => 'edit'
94 94
    end
......
96 96

  
97 97
  def destroy
98 98
    @news.destroy
99
    redirect_to :action => 'index', :project_id => @project
99
    redirect_to project_news_index_path(@project)
100 100
  end
101 101

  
102 102
  private
app/controllers/previews_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class PreviewsController < ApplicationController
19
  before_filter :find_project
19
  before_filter :find_project, :find_attachments
20 20

  
21 21
  def issue
22 22
    @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
23 23
    if @issue
24
      @attachements = @issue.attachments
25 24
      @description = params[:issue] && params[:issue][:description]
26 25
      if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
27 26
        @description = nil
......
37 36
  def news
38 37
    if params[:id].present? && news = News.visible.find_by_id(params[:id])
39 38
      @previewed = news
40
      @attachments = news.attachments
41 39
    end
42 40
    @text = (params[:news] ? params[:news][:description] : nil)
43 41
    render :partial => 'common/preview'
app/controllers/project_enumerations_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
29 29
      flash[:notice] = l(:notice_successful_update)
30 30
    end
31 31

  
32
    redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
32
    redirect_to settings_project_path(@project, :tab => 'activities')
33 33
  end
34 34

  
35 35
  def destroy
......
37 37
      time_entry_activity.destroy(time_entry_activity.parent)
38 38
    end
39 39
    flash[:notice] = l(:notice_successful_update)
40
    redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
40
    redirect_to settings_project_path(@project, :tab => 'activities')
41 41
  end
42

  
43 42
end
app/controllers/projects_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
43 43
  helper :repositories
44 44
  include RepositoriesHelper
45 45
  include ProjectsHelper
46
  helper :members
46 47
  include ActivitiesHelper
47 48
  helper :activities
48 49

  
......
70 71
      format.api  {
71 72
        @offset, @limit = api_offset_and_limit
72 73
        @project_count = Project.visible.count
73
        @projects = Project.visible.all(:offset => @offset, :limit => @limit, :order => 'lft')
74
        @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
74 75
      }
75 76
      format.atom {
76
        projects = Project.visible.find(:all, :order => 'created_on DESC',
77
                                              :limit => Setting.feeds_limit.to_i)
77
        projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
78 78
        render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
79 79
      }
80 80
    end
......
91 91
  end
92 92

  
93 93
  def new
94
    @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
94
    @issue_custom_fields = IssueCustomField.sorted.all
95 95
    @trackers = Tracker.sorted.all
96 96
    @project = Project.new
97 97
    @project.safe_attributes = params[:project]
98 98
  end
99 99

  
100 100
  def create
101
    @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
101
    @issue_custom_fields = IssueCustomField.sorted.all
102 102
    @trackers = Tracker.sorted.all
103 103
    @project = Project.new
104 104
    @project.safe_attributes = params[:project]
......
114 114
      respond_to do |format|
115 115
        format.html {
116 116
          flash[:notice] = l(:notice_successful_create)
117
          redirect_to(params[:continue] ?
118
            {:controller => 'projects', :action => 'new', :project => {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}} :
119
            {:controller => 'projects', :action => 'settings', :id => @project}
120
          )
117
          if params[:continue]
118
            attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
119
            redirect_to new_project_path(attrs)
120
          else
121
            redirect_to settings_project_path(@project)
122
          end
121 123
        }
122 124
        format.api  { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
123 125
      end
......
127 129
        format.api  { render_validation_errors(@project) }
128 130
      end
129 131
    end
130

  
131 132
  end
132 133

  
133 134
  def copy
134
    @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
135
    @issue_custom_fields = IssueCustomField.sorted.all
135 136
    @trackers = Tracker.sorted.all
136
    @root_projects = Project.find(:all,
137
                                  :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
138
                                  :order => 'name')
139 137
    @source_project = Project.find(params[:id])
140 138
    if request.get?
141 139
      @project = Project.copy_from(@source_project)
......
147 145
        if validate_parent_id && @project.copy(@source_project, :only => params[:only])
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff