2019-05-21 14:21:55 +02:00
|
|
|
class AttachmentsController < ApplicationController
|
|
|
|
before_action :authenticate_logged_user!
|
|
|
|
include ActiveStorage::SetBlob
|
|
|
|
|
|
|
|
def show
|
|
|
|
@attachment = @blob.attachments.find(params[:id])
|
2022-11-09 12:33:20 +01:00
|
|
|
|
|
|
|
@user_can_edit = cast_bool(params[:user_can_edit])
|
2023-09-20 16:52:30 +02:00
|
|
|
@direct_upload = cast_bool(params[:direct_upload])
|
2022-12-08 00:15:05 +01:00
|
|
|
@view_as = params[:view_as]&.to_sym
|
2022-11-09 12:33:20 +01:00
|
|
|
@auto_attach_url = params[:auto_attach_url]
|
2020-04-08 17:53:04 +02:00
|
|
|
|
|
|
|
respond_to do |format|
|
2022-05-06 12:25:58 +02:00
|
|
|
format.turbo_stream
|
2020-04-08 18:07:28 +02:00
|
|
|
format.html { redirect_back(fallback_location: root_url) }
|
2020-04-08 17:53:04 +02:00
|
|
|
end
|
2019-05-21 14:21:55 +02:00
|
|
|
end
|
2019-05-29 12:05:28 +02:00
|
|
|
|
|
|
|
def destroy
|
2022-05-06 12:25:58 +02:00
|
|
|
@attachment = @blob.attachments.find(params[:id])
|
|
|
|
@attachment.purge_later
|
|
|
|
flash.notice = 'La pièce jointe a bien été supprimée.'
|
|
|
|
|
2022-11-09 12:33:20 +01:00
|
|
|
@champ_id = params[:champ_id]
|
|
|
|
|
2022-05-06 12:25:58 +02:00
|
|
|
respond_to do |format|
|
|
|
|
format.turbo_stream
|
|
|
|
format.html { redirect_back(fallback_location: root_url) }
|
|
|
|
end
|
2019-05-29 12:05:28 +02:00
|
|
|
end
|
2019-05-21 14:21:55 +02:00
|
|
|
end
|