1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

updated carrierware + validate file upload in front

This commit is contained in:
Sylvain 2020-06-02 17:57:24 +02:00
parent ee3868cb90
commit 1a38a8750b
25 changed files with 124 additions and 76 deletions

View File

@ -91,11 +91,13 @@ GEM
sassc (>= 2.0.0)
builder (3.2.4)
camertron-eprun (1.1.1)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
carrierwave (2.1.0)
activemodel (>= 5.0.0)
activesupport (>= 5.0.0)
addressable (~> 2.6)
image_processing (~> 1.1)
mimemagic (>= 0.3.0)
mini_mime (>= 0.1.3)
caxlsx (3.0.1)
htmlentities (~> 4.3, >= 4.3.4)
mimemagic (~> 0.3)
@ -192,6 +194,9 @@ GEM
ice_cube (~> 0.16)
ice_cube (0.16.3)
ice_nine (0.11.2)
image_processing (1.11.0)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
jaro_winkler (1.5.4)
jbuilder (2.10.0)
activesupport (>= 5.0.0)
@ -230,12 +235,12 @@ GEM
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mime-types-data (3.2020.0512)
mimemagic (0.3.4)
mini_magick (4.10.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
minitest (5.14.1)
minitest-reporters (1.4.2)
ansi
builder
@ -360,6 +365,8 @@ GEM
unicode-display_width (~> 1.4.0)
ruby-progressbar (1.10.1)
ruby-rc4 (0.1.5)
ruby-vips (2.0.17)
ffi (~> 1.9)
ruby2_keywords (0.0.2)
rubyzip (1.3.0)
safe_yaml (1.0.5)

View File

@ -130,7 +130,7 @@
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new" translate>{{ 'app.shared.plan.attach_an_information_sheet' }}</span>
<span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span><input type="file"
name="plan[plan_file_attributes][attachment]"
accept="image/*, application/pdf"></span>
accept="image/jpeg,image/gif,image/png,application/pdf"></span>
<a class="input-group-addon btn btn-danger fileinput-exists" data-dismiss="fileinput" ng-click="deleteFile(file || plan.plan_file_attributes)"><i class="fa fa-trash-o"></i></a>
</div>

View File

@ -30,7 +30,7 @@
</div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">{{ 'app.shared.event.choose_a_picture' | translate }} <i class="fa fa-upload fa-fw"></i></span><span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span>
<input type="file" name="event[event_image_attributes][attachment]"></span>
<input type="file" name="event[event_image_attributes][attachment]" accept="image/jpeg,image/gif,image/png"></span>
<a class="btn btn-danger fileinput-exists" data-dismiss="fileinput"><i class="fa fa-trash-o"></i></a>
</div>
</div>
@ -66,7 +66,7 @@
<i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename">{{file.attachment}}</span>
</div>
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new" translate>{{ 'app.shared.buttons.browse' }}</span>
<span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span><input type="file" name="event[event_files_attributes][][attachment]"></span>
<span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span><input type="file" name="event[event_files_attributes][][attachment]" accept="application/pdf"></span>
<a class="input-group-addon btn btn-danger fileinput-exists" data-dismiss="fileinput" ng-click="deleteFile(file)"><i class="fa fa-trash-o"></i></a>
</div>

View File

@ -45,7 +45,7 @@
<input type="file"
ng-model="machine.machine_image"
name="machine[machine_image_attributes][attachment]"
accept="image/*"
accept="image/jpeg,image/gif,image/png"
required
bs-jasny-fileinput>
</span>

View File

@ -30,7 +30,9 @@
</div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">{{ 'app.shared.project.add_an_illustration' | translate }} <i class="fa fa-upload fa-fw"></i></span><span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span>
<input type="file" name="project[project_image_attributes][attachment]"></span>
<input type="file"
name="project[project_image_attributes][attachment]"
accept="image/jpeg,image/gif,image/png"></span>
<a class="btn btn-danger fileinput-exists" data-dismiss="fileinput" translate>{{ 'app.shared.buttons.delete' }}</a>
</div>
</div>
@ -51,7 +53,9 @@
<i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename">{{file.attachment}}</span>
</div>
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new" translate>{{ 'app.shared.buttons.browse' }}</span>
<span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span><input type="file" name="project[project_caos_attributes][][attachment]"></span>
<span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span>
<input type="file" name="project[project_caos_attributes][][attachment]" accept="<%= "."+ENV['ALLOWED_EXTENSIONS'].split(' ').join(',.') %>">
</span>
<a class="input-group-addon btn btn-danger fileinput-exists" data-dismiss="fileinput" ng-click="deleteFile(file)"><i class="fa fa-trash-o"></i></a>
</div>
</div>
@ -115,7 +119,10 @@
</div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">{{ 'app.shared.buttons.browse' | translate }} <i class="fa fa-upload fa-fw"></i></span><span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span>
<input type="file" name="project[project_steps_attributes][][project_step_images_attributes][][attachment]"></span>
<input type="file"
name="project[project_steps_attributes][][project_step_images_attributes][][attachment]"
accept="image/jpeg,image/gif,image/png">
</span>
<a class="btn btn-danger fileinput-exists" data-dismiss="fileinput" ng-click="deleteProjectStepImage(step, image)" translate>{{ 'app.shared.buttons.delete' }}</a>
</div>
</div>

View File

@ -23,7 +23,7 @@
ng-hide="preventField['profile.avatar'] && user.profile.user_avatar.attachment_url && !userForm['user[profile_attributes][user_avatar_attributes]'].$dirty">
<span class="fileinput-new" translate>{{ 'app.shared.user.add_an_avatar' }}</span>
<span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span>
<input type="file" name="user[profile_attributes][user_avatar_attributes][attachment]">
<input type="file" name="user[profile_attributes][user_avatar_attributes][attachment]" accept="image/jpeg,image/gif,image/png">
</span>
<button class="btn btn-danger fileinput-exists"

View File

@ -32,7 +32,7 @@
id="space_image"
ng-model="space.space_image"
name="space[space_image_attributes][attachment]"
accept="image/*"
accept="image/jpeg,image/gif,image/png"
required
bs-jasny-fileinput>
</span>
@ -98,8 +98,11 @@
<div class="form-control" data-trigger="fileinput">
<i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename">{{file.attachment}}</span>
</div>
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new" translate>{{ 'app.shared.space.attach_a_file' }}</span>
<span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span><input type="file" name="space[space_files_attributes][][attachment]" accept=".pdf"></span>
<span class="input-group-addon btn btn-default btn-file">
<span class="fileinput-new" translate>{{ 'app.shared.space.attach_a_file' }}</span>
<span class="fileinput-exists" translate>{{ 'app.shared.buttons.change' }}</span>
<input type="file" name="space[space_files_attributes][][attachment]" accept="application/pdf">
</span>
<a class="input-group-addon btn btn-danger fileinput-exists" data-dismiss="fileinput" ng-click="deleteFile(file)"><i class="fa fa-trash-o"></i></a>
</div>

View File

@ -1,5 +1,7 @@
# encoding: utf-8
# frozen_string_literal: true
# CarrierWave uploader for CustomAssets (Admin defined assets).
# This file defines the parameters for these uploads.
class CustomAssetsUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
@ -45,8 +47,8 @@ class CustomAssetsUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(pdf png jpeg jpg ico)
def extension_whitelist
%w[pdf png jpeg jpg ico]
end
# Override the filename of the uploaded files:

View File

@ -40,7 +40,7 @@ class EventFileUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
def extension_whitelist
%w[pdf]
end

View File

@ -1,3 +1,7 @@
# frozen_string_literal: true
# CarrierWave uploader for images illustrating the Events.
# This file defines the parameters for these uploads.
class EventImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
@ -41,21 +45,21 @@ class EventImageUploader < CarrierWave::Uploader::Base
# end
version :large do
process :resize_to_fit => [1000, 700]
process resize_to_fit: [1000, 700]
end
version :medium do
process :resize_to_fit => [700, 400]
process resize_to_fit: [700, 400]
end
version :small do
process :resize_to_fit => [260, 260]
process resize_to_fit: [260, 260]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
def extension_whitelist
%w[jpg jpeg gif png]
end
# Override the filename of the uploaded files:

View File

@ -22,7 +22,7 @@ class ImportUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
['csv']
def extension_whitelist
%w[csv]
end
end

View File

@ -1,7 +1,10 @@
# frozen_string_literal: true
# CarrierWave uploader for Machine attachments
class MachineFileUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
#include CarrierWave::MiniMagick
# include CarrierWave::MiniMagick
include UploadHelper
# Choose what kind of storage to use for this uploader:
@ -37,13 +40,13 @@ class MachineFileUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(pdf)
def extension_whitelist
%w[pdf]
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
#def filename
#"avatar.#{file.extension}" if original_filename
#end
# def filename
# "avatar.#{file.extension}" if original_filename
# end
end

View File

@ -1,3 +1,7 @@
# frozen_string_literal: true
# CarrierWave uploader for images illustrating the Machines.
# This file defines the parameters for these uploads.
class MachineImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
@ -37,17 +41,17 @@ class MachineImageUploader < CarrierWave::Uploader::Base
# Create different versions of your uploaded files:
version :large do
process :resize_to_fit => [1000, 700]
process resize_to_fit: [1000, 700]
end
version :medium do
process :resize_to_fit => [700, 400]
process resize_to_fit: [700, 400]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
def extension_whitelist
%w[jpg jpeg gif png]
end
# Override the filename of the uploaded files:

View File

@ -1,7 +1,10 @@
# frozen_string_literal: true
# CarrierWave uploader for the description file of the Plans
class PlanFileUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
#include CarrierWave::MiniMagick
# include CarrierWave::MiniMagick
include UploadHelper
# Choose what kind of storage to use for this uploader:
@ -37,13 +40,13 @@ class PlanFileUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(pdf png jpeg jpg)
def extension_whitelist
%w[pdf png jpeg jpg]
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
#def filename
#"avatar.#{file.extension}" if original_filename
#end
# def filename
# "avatar.#{file.extension}" if original_filename
# end
end

View File

@ -1,3 +1,7 @@
# frozen_string_literal: true
# CarrierWave uploader for user's avatar.
# This file defines the parameters for these uploads.
class ProfilImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
@ -37,21 +41,21 @@ class ProfilImageUploader < CarrierWave::Uploader::Base
# Create different versions of your uploaded files:
version :normal do
process :resize_to_fit => [140, 140]
process resize_to_fit: [140, 140]
end
version :small do
process :resize_to_fit => [80, 80]
process resize_to_fit: [80, 80]
end
version :tiny do
process :resize_to_fit => [40, 40]
process resize_to_fit: [40, 40]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
def extension_whitelist
%w[jpg jpeg gif png]
end
# Override the filename of the uploaded files:

View File

@ -22,7 +22,7 @@ class ProjectCaoUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
def extension_whitelist
ENV['ALLOWED_EXTENSIONS'].split(' ')
end
end

View File

@ -28,7 +28,7 @@ class ProjectImageUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
def extension_whitelist
%w[jpg jpeg gif png]
end

View File

@ -1,7 +1,10 @@
# frozen_string_literal: true
# CarrierWave uploader for Space attachments
class SpaceFileUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
#include CarrierWave::MiniMagick
# include CarrierWave::MiniMagick
include UploadHelper
# Choose what kind of storage to use for this uploader:
@ -37,13 +40,13 @@ class SpaceFileUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(pdf)
def extension_whitelist
%w[pdf]
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
#def filename
#"avatar.#{file.extension}" if original_filename
#end
# def filename
# "avatar.#{file.extension}" if original_filename
# end
end

View File

@ -1,3 +1,7 @@
# frozen_string_literal: true
# CarrierWave uploader for images illustrating the Spaces.
# This file defines the parameters for these uploads.
class SpaceImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
@ -37,17 +41,17 @@ class SpaceImageUploader < CarrierWave::Uploader::Base
# Create different versions of your uploaded files:
version :large do
process :resize_to_fit => [1000, 700]
process resize_to_fit: [1000, 700]
end
version :medium do
process :resize_to_fit => [700, 400]
process resize_to_fit: [700, 400]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
def extension_whitelist
%w[jpg jpeg gif png]
end
# Override the filename of the uploaded files:

View File

@ -1,3 +1,7 @@
# frozen_string_literal: true
# CarrierWave uploader for images illustrating the Trainings.
# This file defines the parameters for these uploads.
class TrainingImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
@ -37,17 +41,17 @@ class TrainingImageUploader < CarrierWave::Uploader::Base
# Create different versions of your uploaded files:
version :large do
process :resize_to_fit => [1000, 700]
process resize_to_fit: [1000, 700]
end
version :medium do
process :resize_to_fit => [700, 400]
process resize_to_fit: [700, 400]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
def extension_whitelist
%w[jpg jpeg gif png]
end
# Override the filename of the uploaded files:

View File

@ -16,8 +16,8 @@ en:
carrierwave_processing_error: "failed to be processed"
carrierwave_integrity_error: "is not of an allowed file type"
carrierwave_download_error: "could not be downloaded"
extension_white_list_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
extension_black_list_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}"
extension_whitelist_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
extension_blacklist_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}"
rmagick_processing_error: "Failed to manipulate with rmagick, maybe it is not an image? Original Error: %{e}"
mime_types_processing_error: "Failed to process file with MIME::Types, maybe not valid content-type? Original Error: %{e}"
mini_magick_processing_error: "Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: %{e}"

View File

@ -16,8 +16,8 @@ es:
carrierwave_processing_error: "no se pudo procesar"
carrierwave_integrity_error: "es un tipo de archivo no permitido"
carrierwave_download_error: "no pudo ser descargado"
extension_white_list_error: "No puede subir archivos con extensión %{extension}, tipos permitidos: %{allowed_types}"
extension_black_list_error: "No puede subir archivos con extensión %{extension}, tipos prohibidos: %{prohibited_types}"
extension_whitelist_error: "No puede subir archivos con extensión %{extension}, tipos permitidos: %{allowed_types}"
extension_blacklist_error: "No puede subir archivos con extensión %{extension}, tipos prohibidos: %{prohibited_types}"
rmagick_processing_error: "Error al manipular con rmagick, ¿Está seguro de que el archivo es una imagen? Error original: %{e}"
mime_types_processing_error: "Error al procesar archivo con MIME::Types, puede ser que el contenido no sea válido. Error original: %{e}"
mini_magick_processing_error: "Error al editar con MiniMagick, ¿Está seguro de que el archivo es una imagen? Error original: %{e}"

View File

@ -16,8 +16,8 @@ fr:
carrierwave_processing_error: "n'a pas pu être traité"
carrierwave_integrity_error: "n'est pas d'un type de fichier autorisé"
carrierwave_download_error: "ne peut pas être téléchargé"
extension_white_list_error: "Vous n'êtes pas autorisé à envoyer des fichiers %{extension}, les types autorisés sont : %{allowed_types}"
extension_black_list_error: "Vous n'êtes pas autorisé à envoyer des fichiers %{extension}, les types interdits sont : %{prohibited_types}"
extension_whitelist_error: "Vous n'êtes pas autorisé à envoyer des fichiers %{extension}, les types autorisés sont : %{allowed_types}"
extension_blacklist_error: "Vous n'êtes pas autorisé à envoyer des fichiers %{extension}, les types interdits sont : %{prohibited_types}"
rmagick_processing_error: "La manipulation avec rmagick a échoué, peut-être ne s'agit-il pas d'une image ? Erreur d'origine : %{e}"
mime_types_processing_error: "Le traitement avec MIME::Types a échoué, le content-type est-il correct ? Erreur d'origine : %{e}"
mini_magick_processing_error: "La manipulation avec MiniMagick a échoué, peut-être ne s'agit-il pas d'une image ? Erreur d'origine : %{e}"

View File

@ -16,8 +16,8 @@ pt:
carrierwave_processing_error: "falhou ao ser processado"
carrierwave_integrity_error: "não é de um tipo de arquivo permitido"
carrierwave_download_error: "não pode ser baixado"
extension_white_list_error: "Você não tem permissão para fazer o upload de arquivos com esta extensão %{extension}, tipos permitidos: %{allowed_types}"
extension_black_list_error: "Você não tem permissão para carregar arquivos %{extension}, tipos proibidos: %{prohibited_types}"
extension_whitelist_error: "Você não tem permissão para fazer o upload de arquivos com esta extensão %{extension}, tipos permitidos: %{allowed_types}"
extension_blacklist_error: "Você não tem permissão para carregar arquivos %{extension}, tipos proibidos: %{prohibited_types}"
rmagick_processing_error: "Falha ao manipular com rmagick, talvez não seja uma imagem? Erro original: %{e}"
mime_types_processing_error: "Falha ao processar arquivo com MIME::Types, talvez o conteúdo não seja válido? Erro original: %{e}"
mini_magick_processing_error: "Falha na manipulação com MiniMagick, talvez isso não seja uma imagem? Erro original: %{e}"

View File

@ -16,8 +16,8 @@ zu:
carrierwave_processing_error: "crwdns3165:0crwdne3165:0"
carrierwave_integrity_error: "crwdns3167:0crwdne3167:0"
carrierwave_download_error: "crwdns3169:0crwdne3169:0"
extension_white_list_error: "crwdns3171:0%{extension}crwdnd3171:0%{allowed_types}crwdne3171:0"
extension_black_list_error: "crwdns3173:0%{extension}crwdnd3173:0%{prohibited_types}crwdne3173:0"
extension_whitelist_error: "crwdns3171:0%{extension}crwdnd3171:0%{allowed_types}crwdne3171:0"
extension_blacklist_error: "crwdns3173:0%{extension}crwdnd3173:0%{prohibited_types}crwdne3173:0"
rmagick_processing_error: "crwdns3175:0%{e}crwdne3175:0"
mime_types_processing_error: "crwdns3177:0%{e}crwdne3177:0"
mini_magick_processing_error: "crwdns3179:0%{e}crwdne3179:0"