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')
|
2012-12-27 23:29:11 +00:00
|
|
|
packages = Package.all( :order => 'name' )
|
2012-12-27 20:17:33 +00:00
|
|
|
render :json => {
|
|
|
|
:packages => packages
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
# POST /api/packages
|
2012-12-27 23:29:11 +00:00
|
|
|
def install
|
2012-12-27 20:17:33 +00:00
|
|
|
return if is_not_role('Admin')
|
|
|
|
|
2012-12-27 23:29:11 +00:00
|
|
|
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 => {
|
2012-12-27 23:29:11 +00:00
|
|
|
:success => true
|
2012-12-27 20:17:33 +00:00
|
|
|
}
|
|
|
|
end
|
2012-12-27 23:29:11 +00:00
|
|
|
|
2012-12-27 20:17:33 +00:00
|
|
|
end
|