mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00: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
|
|
@ -111,6 +111,8 @@ class ProjectsController < ApplicationController
|
|||
# Edit the details of the project
|
||||
#
|
||||
def update
|
||||
template = ""
|
||||
|
||||
params['project'] ||= {}
|
||||
if params['project']['state']
|
||||
@new_state = params['project']['state']
|
||||
|
|
@ -137,35 +139,42 @@ class ProjectsController < ApplicationController
|
|||
@contexts = current_user.contexts
|
||||
update_state_counts
|
||||
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?
|
||||
|
||||
elsif boolean_param('update_status')
|
||||
render :template => 'projects/update_status.js.rjs'
|
||||
return
|
||||
template = 'projects/update_status.js.rjs'
|
||||
elsif boolean_param('update_default_context')
|
||||
@initial_context_name = @project.default_context.name
|
||||
render :template => 'projects/update_default_context.js.rjs'
|
||||
return
|
||||
template = 'projects/update_default_context.js.rjs'
|
||||
elsif boolean_param('update_default_tags')
|
||||
render :template => 'projects/update_default_tags.js.rjs'
|
||||
return
|
||||
template = 'projects/update_default_tags.js.rjs'
|
||||
elsif boolean_param('update_project_name')
|
||||
@projects = current_user.projects
|
||||
render :template => 'projects/update_project_name.js.rjs'
|
||||
return
|
||||
template = 'projects/update_project_name.js.rjs'
|
||||
else
|
||||
render :text => success_text || 'Success'
|
||||
return
|
||||
end
|
||||
else
|
||||
init_data_for_sidebar
|
||||
render :template => 'projects/update.js.erb'
|
||||
return
|
||||
template = 'projects/update.js.erb'
|
||||
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
|
||||
|
||||
def edit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue