Mercurial > hg > soundsoftware-site
changeset 156:9d2c8317d42f feature_75
* Add method to WS API controller to permit Embedded plugin to be switched on or off for a project (via /sys/projects/<id>/embedded.xml?key=<key>&enable={0,1})
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Thu, 27 Jan 2011 14:53:41 +0000 |
parents | 1ca23eedd587 |
children | 3f11a076d11b |
files | app/controllers/sys_controller.rb config/routes.rb |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/sys_controller.rb Thu Jan 27 11:04:34 2011 +0000 +++ b/app/controllers/sys_controller.rb Thu Jan 27 14:53:41 2011 +0000 @@ -55,6 +55,31 @@ render :nothing => true, :status => 404 end + def set_embedded_active + project = Project.find(params[:id]) + mods = project.enabled_modules + enable = (params[:enable] == "1") + if mods.detect {|m| m.name == "embedded"} + logger.info "Project #{project.name} currently has Embedded enabled" + if !enable + logger.info "Disabling Embedded" + modnames = mods.all(:select => :name).collect{|m| m.name}.reject{|n| n == "embedded"} + project.enabled_module_names = modnames + end + else + logger.info "Project #{project.name} currently has Embedded disabled" + if enable + logger.info "Enabling Embedded" + modnames = mods.all(:select => :name).collect{|m| m.name} + modnames << "embedded" + project.enabled_module_names = modnames + end + end + render :nothing => true, :status => 200 + rescue ActiveRecord::RecordNotFound + render :nothing => true, :status => 404 + end + protected def check_enabled
--- a/config/routes.rb Thu Jan 27 11:04:34 2011 +0000 +++ b/config/routes.rb Thu Jan 27 14:53:41 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/embedded.:format', :action => 'set_embedded_active', :conditions => { :method => :get } #todo: should be post end # Install the default route as the lowest priority.