trabajo-afectivo/app/controllers/packages_controller.rb

35 lines
694 B
Ruby
Raw Normal View History

2012-12-27 20:17:33 +00:00
class PackagesController < ApplicationController
before_filter :authentication_check
# GET /api/packages
def index
return if is_not_role('Admin')
packages = Package.all( :order => 'name' )
2012-12-27 20:17:33 +00:00
render :json => {
:packages => packages
}
end
# POST /api/packages
def install
2012-12-27 20:17:33 +00:00
return if is_not_role('Admin')
Package.install( :string => params[:file_upload].read )
redirect_to '/#package'
end
# DELETE /api/packages
def uninstall
return if is_not_role('Admin')
package = Package.find( params[:id] )
Package.uninstall( :name => package.name, :version => package.version )
2012-12-27 20:17:33 +00:00
render :json => {
:success => true
2012-12-27 20:17:33 +00:00
}
end
2012-12-27 20:17:33 +00:00
end