Converts ProjectsController to use the new API template system.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4456 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d0a3aab2e7
commit
a1f12e3ade
|
@ -52,8 +52,9 @@ class ProjectsController < ApplicationController
|
||||||
format.html {
|
format.html {
|
||||||
@projects = Project.visible.find(:all, :order => 'lft')
|
@projects = Project.visible.find(:all, :order => 'lft')
|
||||||
}
|
}
|
||||||
format.xml {
|
format.api {
|
||||||
@projects = Project.visible.find(:all, :order => 'lft')
|
@projects = Project.visible.find(:all, :order => 'lft')
|
||||||
|
render :template => 'projects/index.apit'
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
projects = Project.visible.find(:all, :order => 'created_on DESC',
|
projects = Project.visible.find(:all, :order => 'created_on DESC',
|
||||||
|
@ -93,12 +94,12 @@ class ProjectsController < ApplicationController
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
||||||
}
|
}
|
||||||
format.xml { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
format.api { render :template => 'projects/show.apit', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'new' }
|
format.html { render :action => 'new' }
|
||||||
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
|
format.api { render_validation_errors(@project) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml
|
format.api { render :template => 'projects/show.apit'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -194,7 +195,7 @@ class ProjectsController < ApplicationController
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'settings', :id => @project
|
redirect_to :action => 'settings', :id => @project
|
||||||
}
|
}
|
||||||
format.xml { head :ok }
|
format.api { head :ok }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -202,7 +203,7 @@ class ProjectsController < ApplicationController
|
||||||
settings
|
settings
|
||||||
render :action => 'settings'
|
render :action => 'settings'
|
||||||
}
|
}
|
||||||
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
|
format.api { render_validation_errors(@project) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -233,11 +234,11 @@ class ProjectsController < ApplicationController
|
||||||
if request.get?
|
if request.get?
|
||||||
# display confirmation view
|
# display confirmation view
|
||||||
else
|
else
|
||||||
if params[:format] == 'xml' || 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 :controller => 'admin', :action => 'projects' }
|
||||||
format.xml { head :ok }
|
format.api { head :ok }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
api.array :projects do
|
||||||
|
@projects.each do |project|
|
||||||
|
api.project do
|
||||||
|
api.id project.id
|
||||||
|
api.name project.name
|
||||||
|
api.identifier project.identifier
|
||||||
|
api.description project.description
|
||||||
|
api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
|
||||||
|
api.array :custom_fields do
|
||||||
|
project.visible_custom_field_values.each do |custom_value|
|
||||||
|
api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
|
||||||
|
end
|
||||||
|
end unless project.custom_field_values.empty?
|
||||||
|
api.created_on project.created_on
|
||||||
|
api.updated_on project.updated_on
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,19 +0,0 @@
|
||||||
xml.instruct!
|
|
||||||
xml.projects :type => 'array' do
|
|
||||||
@projects.each do |project|
|
|
||||||
xml.project do
|
|
||||||
xml.id project.id
|
|
||||||
xml.name project.name
|
|
||||||
xml.identifier project.identifier
|
|
||||||
xml.description project.description
|
|
||||||
xml.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
|
|
||||||
xml.custom_fields do
|
|
||||||
project.visible_custom_field_values.each do |custom_value|
|
|
||||||
xml.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
|
|
||||||
end
|
|
||||||
end unless project.custom_field_values.empty?
|
|
||||||
xml.created_on project.created_on
|
|
||||||
xml.updated_on project.updated_on
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
api.project do
|
||||||
|
api.id @project.id
|
||||||
|
api.name @project.name
|
||||||
|
api.identifier @project.identifier
|
||||||
|
api.description @project.description
|
||||||
|
api.homepage @project.homepage
|
||||||
|
|
||||||
|
api.array :custom_fields do
|
||||||
|
@project.visible_custom_field_values.each do |custom_value|
|
||||||
|
api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
|
||||||
|
end
|
||||||
|
end unless @project.custom_field_values.empty?
|
||||||
|
|
||||||
|
api.created_on @project.created_on
|
||||||
|
api.updated_on @project.updated_on
|
||||||
|
|
||||||
|
api.array :trackers do
|
||||||
|
@project.trackers.each do |tracker|
|
||||||
|
api.tracker(:id => tracker.id, :name => tracker.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,23 +0,0 @@
|
||||||
xml.instruct!
|
|
||||||
xml.project do
|
|
||||||
xml.id @project.id
|
|
||||||
xml.name @project.name
|
|
||||||
xml.identifier @project.identifier
|
|
||||||
xml.description @project.description
|
|
||||||
xml.homepage @project.homepage
|
|
||||||
|
|
||||||
xml.custom_fields do
|
|
||||||
@project.visible_custom_field_values.each do |custom_value|
|
|
||||||
xml.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
|
|
||||||
end
|
|
||||||
end unless @project.custom_field_values.empty?
|
|
||||||
|
|
||||||
xml.created_on @project.created_on
|
|
||||||
xml.updated_on @project.updated_on
|
|
||||||
|
|
||||||
xml.trackers do
|
|
||||||
@project.trackers.each do |tracker|
|
|
||||||
xml.tracker(:id => tracker.id, :name => tracker.name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in New Issue