2019-06-04 03:40:48 +00:00
|
|
|
# Copyright (C) 2012-2017 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
|
|
|
class KnowledgeBase::Answer::AttachmentsController < ApplicationController
|
|
|
|
prepend_before_action :authentication_check
|
2020-03-19 09:39:51 +00:00
|
|
|
prepend_before_action :authorize!
|
2019-06-04 03:40:48 +00:00
|
|
|
|
|
|
|
before_action :fetch_answer
|
|
|
|
|
|
|
|
def create
|
2020-02-19 16:41:25 +00:00
|
|
|
@answer.add_attachment params[:file]
|
2019-06-04 03:40:48 +00:00
|
|
|
|
2020-02-19 16:41:25 +00:00
|
|
|
render json: @answer.assets({})
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2020-02-19 16:41:25 +00:00
|
|
|
@answer.remove_attachment params[:id]
|
2019-06-04 03:40:48 +00:00
|
|
|
|
2020-02-19 16:41:25 +00:00
|
|
|
render json: @answer.assets({})
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_answer
|
|
|
|
@answer = KnowledgeBase::Answer.find params[:answer_id]
|
|
|
|
end
|
|
|
|
end
|