trabajo-afectivo/app/controllers/knowledge_base/answer/attachments_controller.rb

34 lines
757 B
Ruby
Raw Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
2019-06-04 03:40:48 +00:00
class KnowledgeBase::Answer::AttachmentsController < ApplicationController
prepend_before_action :authentication_check
before_action :authorize!
2019-06-04 03:40:48 +00:00
before_action :fetch_answer
def create
@answer.add_attachment params[:file]
2019-06-04 03:40:48 +00:00
render json: @answer.assets({})
2019-06-04 03:40:48 +00:00
end
def destroy
@answer.remove_attachment params[:id]
2019-06-04 03:40:48 +00:00
render json: @answer.assets({})
2019-06-04 03:40:48 +00:00
end
def clone_to_form
new_attachments = @answer.clone_attachments('UploadCache', params[:form_id], only_attached_attachments: true)
render json: {
attachments: new_attachments
}
end
2019-06-04 03:40:48 +00:00
private
def fetch_answer
@answer = KnowledgeBase::Answer.find params[:answer_id]
end
end