Use named routes in controllers.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10983 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-12-11 19:39:47 +00:00
parent 60d06d8c17
commit 8ab9215ea8
22 changed files with 117 additions and 88 deletions

View File

@ -334,6 +334,16 @@ class ApplicationController < ActionController::Base
url url
end end
# Returns the path to project issues or to the cross-project
# issue list if project is nil
def _issues_path(project, *args)
if project
project_issues_path(project, *args)
else
issues_path(*args)
end
end
def redirect_back_or_default(default) def redirect_back_or_default(default)
back_url = params[:back_url].to_s back_url = params[:back_url].to_s
if back_url.present? if back_url.present?

View File

@ -42,7 +42,7 @@ class IssueStatusesController < ApplicationController
@issue_status = IssueStatus.new(params[:issue_status]) @issue_status = IssueStatus.new(params[:issue_status])
if request.post? && @issue_status.save if request.post? && @issue_status.save
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index' redirect_to issue_statuses_path
else else
render :action => 'new' render :action => 'new'
end end
@ -56,7 +56,7 @@ class IssueStatusesController < ApplicationController
@issue_status = IssueStatus.find(params[:id]) @issue_status = IssueStatus.find(params[:id])
if request.put? && @issue_status.update_attributes(params[:issue_status]) if request.put? && @issue_status.update_attributes(params[:issue_status])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index' redirect_to issue_statuses_path
else else
render :action => 'edit' render :action => 'edit'
end end
@ -64,10 +64,10 @@ class IssueStatusesController < ApplicationController
def destroy def destroy
IssueStatus.find(params[:id]).destroy IssueStatus.find(params[:id]).destroy
redirect_to :action => 'index' redirect_to issue_statuses_path
rescue rescue
flash[:error] = l(:error_unable_delete_issue_status) flash[:error] = l(:error_unable_delete_issue_status)
redirect_to :action => 'index' redirect_to issue_statuses_path
end end
def update_issue_done_ratio def update_issue_done_ratio
@ -76,6 +76,6 @@ class IssueStatusesController < ApplicationController
else else
flash[:error] = l(:error_issue_done_ratios_not_updated) flash[:error] = l(:error_issue_done_ratios_not_updated)
end end
redirect_to :action => 'index' redirect_to issue_statuses_path
end end
end end

View File

@ -145,8 +145,12 @@ class IssuesController < ApplicationController
format.html { format.html {
render_attachment_warning_if_needed(@issue) render_attachment_warning_if_needed(@issue)
flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject)) flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
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?} } : if params[:continue]
{ :action => 'show', :id => @issue }) attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
redirect_to new_project_issue_path(@issue.project, :issue => attrs)
else
redirect_to issue_path(@issue)
end
} }
format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
end end
@ -187,7 +191,7 @@ class IssuesController < ApplicationController
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } format.html { redirect_back_or_default issue_path(@issue) }
format.api { render_api_ok } format.api { render_api_ok }
end end
else else
@ -270,12 +274,12 @@ class IssuesController < ApplicationController
if params[:follow] if params[:follow]
if @issues.size == 1 && moved_issues.size == 1 if @issues.size == 1 && moved_issues.size == 1
redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first redirect_to issue_path(moved_issues.first)
elsif moved_issues.map(&:project).uniq.size == 1 elsif moved_issues.map(&:project).uniq.size == 1
redirect_to :controller => 'issues', :action => 'index', :project_id => moved_issues.map(&:project).first redirect_to project_issues_path(moved_issues.map(&:project).first)
end end
else else
redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project}) redirect_back_or_default _issues_path(@project)
end end
end end
@ -308,7 +312,7 @@ class IssuesController < ApplicationController
end end
end end
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } format.html { redirect_back_or_default _issues_path(@project) }
format.api { render_api_ok } format.api { render_api_ok }
end end
end end

View File

@ -80,7 +80,7 @@ class JournalsController < ApplicationController
@journal.destroy if @journal.details.empty? && @journal.notes.blank? @journal.destroy if @journal.details.empty? && @journal.notes.blank?
call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params})
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id } format.html { redirect_to issue_path(@journal.journalized) }
format.js { render :action => 'update' } format.js { render :action => 'update' }
end end
else else

View File

@ -63,7 +63,7 @@ class MembersController < ApplicationController
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } format.html { redirect_to_settings_in_projects }
format.js { @members = members } format.js { @members = members }
format.api { format.api {
@member = members.first @member = members.first
@ -82,7 +82,7 @@ class MembersController < ApplicationController
end end
saved = @member.save saved = @member.save
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } format.html { redirect_to_settings_in_projects }
format.js format.js
format.api { format.api {
if saved if saved
@ -99,7 +99,7 @@ class MembersController < ApplicationController
@member.destroy @member.destroy
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } format.html { redirect_to_settings_in_projects }
format.js format.js
format.api { format.api {
if @member.destroyed? if @member.destroyed?
@ -115,4 +115,10 @@ class MembersController < ApplicationController
@principals = Principal.active.not_member_of(@project).like(params[:q]).all(:limit => 100) @principals = Principal.active.not_member_of(@project).like(params[:q]).all(:limit => 100)
render :layout => false render :layout => false
end end
private
def redirect_to_settings_in_projects
redirect_to settings_project_path(@project, :tab => 'members')
end
end end

View File

@ -59,7 +59,7 @@ class MyController < ApplicationController
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
set_language_if_valid @user.language set_language_if_valid @user.language
flash[:notice] = l(:notice_account_updated) flash[:notice] = l(:notice_account_updated)
redirect_to :action => 'account' redirect_to my_account_path
return return
end end
end end
@ -69,7 +69,7 @@ class MyController < ApplicationController
def destroy def destroy
@user = User.current @user = User.current
unless @user.own_account_deletable? unless @user.own_account_deletable?
redirect_to :action => 'account' redirect_to my_account_path
return return
end end
@ -88,7 +88,7 @@ class MyController < ApplicationController
@user = User.current @user = User.current
unless @user.change_password_allowed? unless @user.change_password_allowed?
flash[:error] = l(:notice_can_t_change_password) flash[:error] = l(:notice_can_t_change_password)
redirect_to :action => 'account' redirect_to my_account_path
return return
end end
if request.post? if request.post?
@ -96,7 +96,7 @@ class MyController < ApplicationController
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
if @user.save if @user.save
flash[:notice] = l(:notice_account_password_updated) flash[:notice] = l(:notice_account_password_updated)
redirect_to :action => 'account' redirect_to my_account_path
end end
else else
flash[:error] = l(:notice_account_wrong_password) flash[:error] = l(:notice_account_wrong_password)
@ -114,7 +114,7 @@ class MyController < ApplicationController
User.current.rss_key User.current.rss_key
flash[:notice] = l(:notice_feeds_access_key_reseted) flash[:notice] = l(:notice_feeds_access_key_reseted)
end end
redirect_to :action => 'account' redirect_to my_account_path
end end
# Create a new API key # Create a new API key
@ -127,7 +127,7 @@ class MyController < ApplicationController
User.current.api_key User.current.api_key
flash[:notice] = l(:notice_api_access_key_reseted) flash[:notice] = l(:notice_api_access_key_reseted)
end end
redirect_to :action => 'account' redirect_to my_account_path
end end
# User's page layout configuration # User's page layout configuration
@ -156,7 +156,7 @@ class MyController < ApplicationController
layout['top'].unshift block layout['top'].unshift block
@user.pref[:my_page_layout] = layout @user.pref[:my_page_layout] = layout
@user.pref.save @user.pref.save
redirect_to :action => 'page_layout' redirect_to my_page_layout_path
end end
# Remove a block to user's page # Remove a block to user's page
@ -169,7 +169,7 @@ class MyController < ApplicationController
%w(top left right).each {|f| (layout[f] ||= []).delete block } %w(top left right).each {|f| (layout[f] ||= []).delete block }
@user.pref[:my_page_layout] = layout @user.pref[:my_page_layout] = layout
@user.pref.save @user.pref.save
redirect_to :action => 'page_layout' redirect_to my_page_layout_path
end end
# Change blocks order on user's page # Change blocks order on user's page

View File

@ -73,7 +73,7 @@ class NewsController < ApplicationController
if @news.save if @news.save
render_attachment_warning_if_needed(@news) render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'news', :action => 'index', :project_id => @project redirect_to project_news_index_path(@project)
else else
render :action => 'new' render :action => 'new'
end end
@ -88,7 +88,7 @@ class NewsController < ApplicationController
if @news.save if @news.save
render_attachment_warning_if_needed(@news) render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'show', :id => @news redirect_to news_path(@news)
else else
render :action => 'edit' render :action => 'edit'
end end
@ -96,7 +96,7 @@ class NewsController < ApplicationController
def destroy def destroy
@news.destroy @news.destroy
redirect_to :action => 'index', :project_id => @project redirect_to project_news_index_path(@project)
end end
private private

View File

@ -29,7 +29,7 @@ class ProjectEnumerationsController < ApplicationController
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
end end
redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project redirect_to settings_project_path(@project, :tab => 'activities')
end end
def destroy def destroy
@ -37,7 +37,6 @@ class ProjectEnumerationsController < ApplicationController
time_entry_activity.destroy(time_entry_activity.parent) time_entry_activity.destroy(time_entry_activity.parent)
end end
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project redirect_to settings_project_path(@project, :tab => 'activities')
end end
end end

View File

@ -90,10 +90,12 @@ class ProjectsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to(params[:continue] ? if params[:continue]
{:controller => 'projects', :action => 'new', :project => {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}} : attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
{:controller => 'projects', :action => 'settings', :id => @project} redirect_to new_project_path(attrs)
) else
redirect_to settings_project_path(@project)
end
} }
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end end
@ -103,7 +105,6 @@ class ProjectsController < ApplicationController
format.api { render_validation_errors(@project) } format.api { render_validation_errors(@project) }
end end
end end
end end
def copy def copy
@ -120,13 +121,13 @@ class ProjectsController < ApplicationController
if validate_parent_id && @project.copy(@source_project, :only => params[:only]) if validate_parent_id && @project.copy(@source_project, :only => params[:only])
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'settings', :id => @project redirect_to settings_project_path(@project)
elsif !@project.new_record? elsif !@project.new_record?
# Project was created # Project was created
# But some objects were not copied due to validation failures # But some objects were not copied due to validation failures
# (eg. issues from disabled trackers) # (eg. issues from disabled trackers)
# TODO: inform about that # TODO: inform about that
redirect_to :controller => 'projects', :action => 'settings', :id => @project redirect_to settings_project_path(@project)
end end
end end
end end
@ -182,7 +183,7 @@ class ProjectsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'settings', :id => @project redirect_to settings_project_path(@project)
} }
format.api { render_api_ok } format.api { render_api_ok }
end end
@ -200,7 +201,7 @@ class ProjectsController < ApplicationController
def modules def modules
@project.enabled_module_names = params[:enabled_module_names] @project.enabled_module_names = params[:enabled_module_names]
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'settings', :id => @project, :tab => 'modules' redirect_to settings_project_path(@project, :tab => 'modules')
end end
def archive def archive
@ -209,12 +210,12 @@ class ProjectsController < ApplicationController
flash[:error] = l(:error_can_not_archive_project) flash[:error] = l(:error_can_not_archive_project)
end end
end end
redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) redirect_to admin_projects_path(:status => params[:status])
end end
def unarchive def unarchive
@project.unarchive if request.post? && !@project.active? @project.unarchive if request.post? && !@project.active?
redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) redirect_to admin_projects_path(:status => params[:status])
end end
def close def close
@ -233,7 +234,7 @@ class ProjectsController < ApplicationController
if api_request? || params[:confirm] if api_request? || params[:confirm]
@project_to_destroy.destroy @project_to_destroy.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'admin', :action => 'projects' } format.html { redirect_to admin_projects_path }
format.api { render_api_ok } format.api { render_api_ok }
end end
end end

View File

@ -60,7 +60,7 @@ class QueriesController < ApplicationController
if @query.save if @query.save
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :query_id => @query redirect_to _issues_path(@project, :query_id => @query)
else else
render :action => 'new', :layout => !request.xhr? render :action => 'new', :layout => !request.xhr?
end end
@ -78,7 +78,7 @@ class QueriesController < ApplicationController
if @query.save if @query.save
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :query_id => @query redirect_to _issues_path(@project, :query_id => @query)
else else
render :action => 'edit' render :action => 'edit'
end end
@ -86,7 +86,7 @@ class QueriesController < ApplicationController
def destroy def destroy
@query.destroy @query.destroy
redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 redirect_to _issues_path(@project, :set_filter => 1)
end end
private private

View File

@ -58,7 +58,7 @@ class RolesController < ApplicationController
@role.workflow_rules.copy(copy_from) @role.workflow_rules.copy(copy_from)
end end
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index' redirect_to roles_path
else else
@roles = Role.sorted.all @roles = Role.sorted.all
render :action => 'new' render :action => 'new'
@ -71,7 +71,7 @@ class RolesController < ApplicationController
def update def update
if request.put? and @role.update_attributes(params[:role]) if request.put? and @role.update_attributes(params[:role])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index' redirect_to roles_path
else else
render :action => 'edit' render :action => 'edit'
end end
@ -79,10 +79,10 @@ class RolesController < ApplicationController
def destroy def destroy
@role.destroy @role.destroy
redirect_to :action => 'index' redirect_to roles_path
rescue rescue
flash[:error] = l(:error_can_not_remove_role) flash[:error] = l(:error_can_not_remove_role)
redirect_to :action => 'index' redirect_to roles_path
end end
def permissions def permissions
@ -94,7 +94,7 @@ class RolesController < ApplicationController
role.save role.save
end end
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index' redirect_to roles_path
end end
end end

View File

@ -36,7 +36,7 @@ class SettingsController < ApplicationController
Setting[name] = value Setting[name] = value
end end
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'edit', :tab => params[:tab] redirect_to settings_path(:tab => params[:tab])
else else
@options = {} @options = {}
user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]} user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]}
@ -55,7 +55,7 @@ class SettingsController < ApplicationController
if request.post? if request.post?
Setting.send "plugin_#{@plugin.id}=", params[:settings] Setting.send "plugin_#{@plugin.id}=", params[:settings]
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'plugin', :id => @plugin.id redirect_to plugin_settings_path(@plugin.id)
else else
@partial = @plugin.settings[:partial] @partial = @plugin.settings[:partial]
@settings = Setting.send "plugin_#{@plugin.id}" @settings = Setting.send "plugin_#{@plugin.id}"

View File

@ -128,16 +128,24 @@ class TimelogController < ApplicationController
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
if params[:continue] if params[:continue]
if params[:project_id] if params[:project_id]
redirect_to :action => 'new', :project_id => @time_entry.project, :issue_id => @time_entry.issue, options = {
:time_entry => {:issue_id => @time_entry.issue_id, :activity_id => @time_entry.activity_id}, :time_entry => {:issue_id => @time_entry.issue_id, :activity_id => @time_entry.activity_id},
:back_url => params[:back_url] :back_url => params[:back_url]
}
if @time_entry.issue
redirect_to new_project_issue_time_entry_path(@time_entry.project, @time_entry.issue, options)
else
redirect_to new_project_time_entry_path(@time_entry.project, options)
end
else else
redirect_to :action => 'new', options = {
:time_entry => {:project_id => @time_entry.project_id, :issue_id => @time_entry.issue_id, :activity_id => @time_entry.activity_id}, :time_entry => {:project_id => @time_entry.project_id, :issue_id => @time_entry.issue_id, :activity_id => @time_entry.activity_id},
:back_url => params[:back_url] :back_url => params[:back_url]
}
redirect_to new_time_entry_path(options)
end end
else else
redirect_back_or_default :action => 'index', :project_id => @time_entry.project redirect_back_or_default project_time_entries_path(@time_entry.project)
end end
} }
format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) } format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) }
@ -163,7 +171,7 @@ class TimelogController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_back_or_default :action => 'index', :project_id => @time_entry.project redirect_back_or_default project_time_entries_path(@time_entry.project)
} }
format.api { render_api_ok } format.api { render_api_ok }
end end
@ -194,7 +202,7 @@ class TimelogController < ApplicationController
end end
end end
set_flash_from_bulk_time_entry_save(@time_entries, unsaved_time_entry_ids) set_flash_from_bulk_time_entry_save(@time_entries, unsaved_time_entry_ids)
redirect_back_or_default({:controller => 'timelog', :action => 'index', :project_id => @projects.first}) redirect_back_or_default project_time_entries_path(@projects.first)
end end
def destroy def destroy
@ -213,7 +221,7 @@ class TimelogController < ApplicationController
else else
flash[:error] = l(:notice_unable_delete_time_entry) flash[:error] = l(:notice_unable_delete_time_entry)
end end
redirect_back_or_default(:action => 'index', :project_id => @projects.first) redirect_back_or_default project_time_entries_path(@projects.first)
} }
format.api { format.api {
if destroyed if destroyed

View File

@ -48,7 +48,7 @@ class TrackersController < ApplicationController
@tracker.workflow_rules.copy(copy_from) @tracker.workflow_rules.copy(copy_from)
end end
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index' redirect_to trackers_path
return return
end end
new new
@ -64,7 +64,7 @@ class TrackersController < ApplicationController
@tracker = Tracker.find(params[:id]) @tracker = Tracker.find(params[:id])
if @tracker.update_attributes(params[:tracker]) if @tracker.update_attributes(params[:tracker])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index' redirect_to trackers_path
return return
end end
edit edit
@ -78,7 +78,7 @@ class TrackersController < ApplicationController
else else
@tracker.destroy @tracker.destroy
end end
redirect_to :action => 'index' redirect_to trackers_path
end end
def fields def fields
@ -92,7 +92,7 @@ class TrackersController < ApplicationController
end end
end end
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'fields' redirect_to fields_trackers_path
return return
end end
@trackers = Tracker.sorted.all @trackers = Tracker.sorted.all

View File

@ -101,10 +101,11 @@ class UsersController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:notice] = l(:notice_user_successful_create, :id => view_context.link_to(@user.login, user_path(@user))) flash[:notice] = l(:notice_user_successful_create, :id => view_context.link_to(@user.login, user_path(@user)))
redirect_to(params[:continue] ? if params[:continue]
{:controller => 'users', :action => 'new'} : redirect_to new_user_path
{:controller => 'users', :action => 'edit', :id => @user} else
) redirect_to edit_user_path(@user)
end
} }
format.api { render :action => 'show', :status => :created, :location => user_url(@user) } format.api { render :action => 'show', :status => :created, :location => user_url(@user) }
end end
@ -171,7 +172,7 @@ class UsersController < ApplicationController
def destroy def destroy
@user.destroy @user.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default(users_url) } format.html { redirect_back_or_default(users_path) }
format.api { render_api_ok } format.api { render_api_ok }
end end
end end
@ -180,7 +181,7 @@ class UsersController < ApplicationController
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user) @membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
@membership.save @membership.save
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' } format.html { redirect_to edit_user_path(@user, :tab => 'memberships') }
format.js format.js
end end
end end
@ -191,7 +192,7 @@ class UsersController < ApplicationController
@membership.destroy @membership.destroy
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' } format.html { redirect_to edit_user_path(@user, :tab => 'memberships') }
format.js format.js
end end
end end

View File

@ -96,7 +96,7 @@ class VersionsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project redirect_back_or_default settings_project_path(@project, :tab => 'versions')
end end
format.js format.js
format.api do format.api do
@ -125,7 +125,7 @@ class VersionsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project redirect_back_or_default settings_project_path(@project, :tab => 'versions')
} }
format.api { render_api_ok } format.api { render_api_ok }
end end
@ -142,21 +142,21 @@ class VersionsController < ApplicationController
if request.put? if request.put?
@project.close_completed_versions @project.close_completed_versions
end end
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project redirect_to settings_project_path(@project, :tab => 'versions')
end end
def destroy def destroy
if @version.fixed_issues.empty? if @version.fixed_issues.empty?
@version.destroy @version.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project } format.html { redirect_back_or_default settings_project_path(@project, :tab => 'versions') }
format.api { render_api_ok } format.api { render_api_ok }
end end
else else
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:error] = l(:notice_unable_delete_version) flash[:error] = l(:notice_unable_delete_version)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project redirect_to settings_project_path(@project, :tab => 'versions')
} }
format.api { head :unprocessable_entity } format.api { head :unprocessable_entity }
end end

View File

@ -160,10 +160,10 @@ class WikiController < ApplicationController
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
respond_to do |format| respond_to do |format|
format.html { redirect_to :action => 'show', :project_id => @project, :id => @page.title } format.html { redirect_to project_wiki_page_path(@project, @page.title) }
format.api { format.api {
if was_new_page if was_new_page
render :action => 'show', :status => :created, :location => url_for(:controller => 'wiki', :action => 'show', :project_id => @project, :id => @page.title) render :action => 'show', :status => :created, :location => project_wiki_page_path(@project, @page.title)
else else
render_api_ok render_api_ok
end end
@ -200,13 +200,13 @@ class WikiController < ApplicationController
@original_title = @page.pretty_title @original_title = @page.pretty_title
if request.post? && @page.update_attributes(params[:wiki_page]) if request.post? && @page.update_attributes(params[:wiki_page])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'show', :project_id => @project, :id => @page.title redirect_to project_wiki_page_path(@project, @page.title)
end end
end end
def protect def protect
@page.update_attribute :protected, params[:protected] @page.update_attribute :protected, params[:protected]
redirect_to :action => 'show', :project_id => @project, :id => @page.title redirect_to project_wiki_page_path(@project, @page.title)
end end
# show page history # show page history
@ -262,7 +262,7 @@ class WikiController < ApplicationController
end end
@page.destroy @page.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to :action => 'index', :project_id => @project } format.html { redirect_to project_wiki_index_path(@project) }
format.api { render_api_ok } format.api { render_api_ok }
end end
end end
@ -272,7 +272,7 @@ class WikiController < ApplicationController
@content = @page.content_for_version(params[:version]) @content = @page.content_for_version(params[:version])
@content.destroy @content.destroy
redirect_to_referer_or :action => 'history', :id => @page.title, :project_id => @project redirect_to_referer_or history_project_wiki_page_path(@project, @page.title)
end end
# Export wiki to a single pdf or html file # Export wiki to a single pdf or html file

View File

@ -30,7 +30,7 @@ class WikisController < ApplicationController
def destroy def destroy
if request.post? && params[:confirm] && @project.wiki if request.post? && params[:confirm] && @project.wiki
@project.wiki.destroy @project.wiki.destroy
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'wiki' redirect_to settings_project_path(@project, :tab => 'wiki')
end end
end end
end end

View File

@ -38,7 +38,7 @@ class WorkflowsController < ApplicationController
} }
} }
if @role.save if @role.save
redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker, :used_statuses_only => params[:used_statuses_only] redirect_to workflows_edit_path(:role_id => @role, :tracker_id => @tracker, :used_statuses_only => params[:used_statuses_only])
return return
end end
end end
@ -64,7 +64,7 @@ class WorkflowsController < ApplicationController
if request.post? && @role && @tracker if request.post? && @role && @tracker
WorkflowPermission.replace_permissions(@tracker, @role, params[:permissions] || {}) WorkflowPermission.replace_permissions(@tracker, @role, params[:permissions] || {})
redirect_to :action => 'permissions', :role_id => @role, :tracker_id => @tracker, :used_statuses_only => params[:used_statuses_only] redirect_to workflows_permissions_path(:role_id => @role, :tracker_id => @tracker, :used_statuses_only => params[:used_statuses_only])
return return
end end
@ -111,7 +111,7 @@ class WorkflowsController < ApplicationController
else else
WorkflowRule.copy(@source_tracker, @source_role, @target_trackers, @target_roles) WorkflowRule.copy(@source_tracker, @source_role, @target_trackers, @target_roles)
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'copy', :source_tracker_id => @source_tracker, :source_role_id => @source_role redirect_to workflows_copy_path(:source_tracker_id => @source_tracker, :source_role_id => @source_role)
end end
end end
end end

View File

@ -141,7 +141,7 @@ RedmineApp::Application.routes.draw do
end end
match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
resources :wiki, :except => [:index, :new, :create] do resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do
member do member do
get 'rename' get 'rename'
post 'rename' post 'rename'
@ -317,7 +317,7 @@ RedmineApp::Application.routes.draw do
match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post] match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
match 'settings', :controller => 'settings', :action => 'index', :via => :get match 'settings', :controller => 'settings', :action => 'index', :via => :get
match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post] match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post] match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings'
match 'sys/projects', :to => 'sys#projects', :via => :get match 'sys/projects', :to => 'sys#projects', :via => :get
match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post

View File

@ -184,7 +184,7 @@ class ProjectsControllerTest < ActionController::TestCase
assert_difference 'Project.count' do assert_difference 'Project.count' do
post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue' post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue'
end end
assert_redirected_to '/projects/new?' assert_redirected_to '/projects/new'
end end
end end

View File

@ -72,7 +72,7 @@ class SettingsControllerTest < ActionController::TestCase
:notified_events => %w(issue_added issue_updated news_added), :notified_events => %w(issue_added issue_updated news_added),
:emails_footer => 'Test footer' :emails_footer => 'Test footer'
} }
assert_redirected_to '/settings/edit' assert_redirected_to '/settings'
assert_equal 'functional@test.foo', Setting.mail_from assert_equal 'functional@test.foo', Setting.mail_from
assert !Setting.bcc_recipients? assert !Setting.bcc_recipients?
assert_equal %w(issue_added issue_updated news_added), Setting.notified_events assert_equal %w(issue_added issue_updated news_added), Setting.notified_events