2013-06-12 15:59:58 +00:00
|
|
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2012-12-27 20:17:33 +00:00
|
|
|
class PackagesController < ApplicationController
|
|
|
|
before_filter :authentication_check
|
|
|
|
|
2013-08-06 22:10:28 +00:00
|
|
|
# GET /api/v1/packages
|
2012-12-27 20:17:33 +00:00
|
|
|
def index
|
2013-07-19 14:21:44 +00:00
|
|
|
return if deny_if_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
|
|
|
|
|
2013-08-06 22:10:28 +00:00
|
|
|
# POST /api/v1/packages
|
2012-12-27 23:29:11 +00:00
|
|
|
def install
|
2013-07-19 14:21:44 +00:00
|
|
|
return if deny_if_not_role('Admin')
|
2012-12-27 20:17:33 +00:00
|
|
|
|
2012-12-27 23:29:11 +00:00
|
|
|
Package.install( :string => params[:file_upload].read )
|
|
|
|
|
|
|
|
redirect_to '/#package'
|
|
|
|
end
|
|
|
|
|
2013-08-06 22:10:28 +00:00
|
|
|
# DELETE /api/v1/packages
|
2012-12-27 23:29:11 +00:00
|
|
|
def uninstall
|
2013-07-19 14:21:44 +00:00
|
|
|
return if deny_if_not_role('Admin')
|
2012-12-27 23:29:11 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|