Mercurial > hg > soundsoftware-site
changeset 214:e0cbb39c0429 feature_73
* Add method to retrieve external repo URL (via /sys/projects/<id>/external-repository.xml?key=<key>)
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Thu, 10 Feb 2011 14:40:44 +0000 |
parents | ff5112f823e5 |
children | e65d8141194b |
files | app/controllers/sys_controller.rb config/routes.rb |
diffstat | 2 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/sys_controller.rb Tue Feb 08 13:24:51 2011 +0000 +++ b/app/controllers/sys_controller.rb Thu Feb 10 14:40:44 2011 +0000 @@ -55,6 +55,20 @@ render :nothing => true, :status => 404 end + def get_external_repo_url + project = Project.find(params[:id]) + if project.repository + repo = project.repository + if repo.is_external? + render :text => repo.external_url, :status => 200 + else + render :nothing => true, :status => 200 + end + end + rescue ActiveRecord::RecordNotFound + render :nothing => true, :status => 404 + end + protected def check_enabled
--- a/config/routes.rb Tue Feb 08 13:24:51 2011 +0000 +++ b/config/routes.rb Thu Feb 10 14:40:44 2011 +0000 @@ -236,6 +236,7 @@ map.with_options :controller => 'sys' do |sys| sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} + sys.connect 'sys/projects/:id/external-repository.:format', :action => 'get_external_repo_url', :conditions => {:method => :get} end # Install the default route as the lowest priority.