mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-19 16:50:12 +01:00
fix #1173 and fix #1175 where renaming a project or context to an existing name using REST will fail with status 406
This commit is contained in:
parent
8c168538b7
commit
a797b83f86
2 changed files with 30 additions and 14 deletions
|
|
@ -121,6 +121,13 @@ class ContextsController < ApplicationController
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
format.xml {
|
||||||
|
if @saved
|
||||||
|
render :xml => @context.to_xml( :except => :user_id )
|
||||||
|
else
|
||||||
|
render :text => "Error on update: #{@context.errors.full_messages.inject("") {|v, e| v + e + " " }}", :status => 409
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ class ProjectsController < ApplicationController
|
||||||
# Edit the details of the project
|
# Edit the details of the project
|
||||||
#
|
#
|
||||||
def update
|
def update
|
||||||
|
template = ""
|
||||||
|
|
||||||
params['project'] ||= {}
|
params['project'] ||= {}
|
||||||
if params['project']['state']
|
if params['project']['state']
|
||||||
@new_state = params['project']['state']
|
@new_state = params['project']['state']
|
||||||
|
|
@ -137,35 +139,42 @@ class ProjectsController < ApplicationController
|
||||||
@contexts = current_user.contexts
|
@contexts = current_user.contexts
|
||||||
update_state_counts
|
update_state_counts
|
||||||
init_data_for_sidebar
|
init_data_for_sidebar
|
||||||
render :template => 'projects/update.js.erb'
|
|
||||||
return
|
template = 'projects/update.js.erb'
|
||||||
|
|
||||||
# TODO: are these params ever set? or is this dead code?
|
# TODO: are these params ever set? or is this dead code?
|
||||||
|
|
||||||
elsif boolean_param('update_status')
|
elsif boolean_param('update_status')
|
||||||
render :template => 'projects/update_status.js.rjs'
|
template = 'projects/update_status.js.rjs'
|
||||||
return
|
|
||||||
elsif boolean_param('update_default_context')
|
elsif boolean_param('update_default_context')
|
||||||
@initial_context_name = @project.default_context.name
|
@initial_context_name = @project.default_context.name
|
||||||
render :template => 'projects/update_default_context.js.rjs'
|
template = 'projects/update_default_context.js.rjs'
|
||||||
return
|
|
||||||
elsif boolean_param('update_default_tags')
|
elsif boolean_param('update_default_tags')
|
||||||
render :template => 'projects/update_default_tags.js.rjs'
|
template = 'projects/update_default_tags.js.rjs'
|
||||||
return
|
|
||||||
elsif boolean_param('update_project_name')
|
elsif boolean_param('update_project_name')
|
||||||
@projects = current_user.projects
|
@projects = current_user.projects
|
||||||
render :template => 'projects/update_project_name.js.rjs'
|
template = 'projects/update_project_name.js.rjs'
|
||||||
return
|
|
||||||
else
|
else
|
||||||
render :text => success_text || 'Success'
|
render :text => success_text || 'Success'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
init_data_for_sidebar
|
init_data_for_sidebar
|
||||||
render :template => 'projects/update.js.erb'
|
template = 'projects/update.js.erb'
|
||||||
return
|
|
||||||
end
|
end
|
||||||
render :template => 'projects/update.js.erb'
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js { render :template => template }
|
||||||
|
format.html { redirect_to :action => 'index'}
|
||||||
|
format.xml {
|
||||||
|
if @saved
|
||||||
|
render :xml => @project.to_xml( :except => :user_id )
|
||||||
|
else
|
||||||
|
render :text => "Error on update: #{@project.errors.full_messages.inject("") {|v, e| v + e + " " }}", :status => 409
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue