2021-05-19 10:15:51 +00:00
|
|
|
class FolderAppsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
app_id = params[:app_id]
|
|
|
|
|
folder_id = params[:folder_id]
|
2021-05-19 15:39:10 +00:00
|
|
|
|
2021-05-19 10:25:59 +00:00
|
|
|
@app = App.find app_id
|
|
|
|
|
|
|
|
|
|
unless AppPolicy.new(@current_user, @app).update?
|
|
|
|
|
render json: { message: 'Could not add app to folder due to insufficient permissions' }, status: 500
|
2021-05-19 15:39:10 +00:00
|
|
|
return
|
2021-05-19 10:25:59 +00:00
|
|
|
end
|
|
|
|
|
|
2021-05-19 10:20:05 +00:00
|
|
|
folder_app = FolderApp.new(app_id: app_id, folder_id: folder_id)
|
|
|
|
|
|
|
|
|
|
if folder_app.save
|
|
|
|
|
render json: {}
|
|
|
|
|
else
|
|
|
|
|
render json: { message: 'App already in folder' }, status: 500
|
|
|
|
|
end
|
2021-05-19 10:15:51 +00:00
|
|
|
end
|
|
|
|
|
end
|