trabajo-afectivo/app/controllers/packages_controller.rb

35 lines
863 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
2012-12-27 20:17:33 +00:00
class PackagesController < ApplicationController
prepend_before_action { authentication_check && authorize! }
2012-12-27 20:17:33 +00:00
# GET /api/v1/packages
2012-12-27 20:17:33 +00:00
def index
packages = Package.all.order('name')
commands = ['rails zammad:package:migrate', 'rails assets:precompile']
if File.exist?('/usr/bin/zammad')
commands.map! { |s| "zammad run #{s}" }
end
render json: {
packages: packages,
commands: commands
2012-12-27 20:17:33 +00:00
}
end
# POST /api/v1/packages
def install
Package.install(string: params[:file_upload].read)
2013-09-22 22:28:33 +00:00
redirect_to '/#system/package'
end
# DELETE /api/v1/packages
def uninstall
package = Package.find(params[:id])
Package.uninstall(name: package.name, version: package.version)
render json: {
success: true
2012-12-27 20:17:33 +00:00
}
end
end