1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

Image max size is configutable, size by default is 2 megabytes

This commit is contained in:
Peng DU 2016-11-02 15:36:22 +01:00
parent ba5e5752a4
commit f1b749d5f2
10 changed files with 24 additions and 8 deletions

View File

@ -2,10 +2,12 @@
## next release
- Image max size is configutable, size by default is 2 megabytes
- Allow add more picture for project step
- Ability to use HTML in event's descriptions using a WYSIWYG editor
- Fix a bug: statistics graphs were not showing
- In the sign-up modal, the translation for 'i_accept_to_receive_information_from_the_fablab' was not loaded
- [TODO DEPLOY] add `MAX_IMAGE_SIZE` environment variable in `application.yml` and docker env
## v2.4.1 2016 October 11

View File

@ -0,0 +1,7 @@
module ImageValidatorConcern
extend ActiveSupport::Concern
included do
validates :attachment, file_size: { maximum: Rails.application.secrets.max_image_size ? Rails.application.secrets.max_image_size.to_i : 2.megabytes.to_i }
end
end

View File

@ -1,5 +1,4 @@
class EventImage < Asset
include ImageValidatorConcern
mount_uploader :attachment, EventImageUploader
validates :attachment, file_size: { maximum: 2.megabytes.to_i }
end

View File

@ -1,4 +1,4 @@
class PlanImage < Asset
include ImageValidatorConcern
mount_uploader :attachment, PlanImageUploader
validates :attachment, file_size: { maximum: 2.megabytes.to_i }
end

View File

@ -1,5 +1,4 @@
class ProjectImage < Asset
include ImageValidatorConcern
mount_uploader :attachment, ProjectImageUploader
validates :attachment, file_size: { maximum: 2.megabytes.to_i }
end

View File

@ -1,5 +1,4 @@
class ProjectStepImage < Asset
include ImageValidatorConcern
mount_uploader :attachment, ProjectImageUploader
validates :attachment, file_size: { maximum: 2.megabytes.to_i }
end

View File

@ -1,4 +1,4 @@
class UserAvatar < Asset
include ImageValidatorConcern
mount_uploader :attachment, ProfilImageUploader
end

View File

@ -59,3 +59,6 @@ LOG_LEVEL: 'debug'
ALLOWED_EXTENSIONS: pdf ai eps cad math svg stl dxf dwg obj step iges igs 3dm 3dmf doc docx png ino scad fcad skp sldprt sldasm slddrw slddrt tex latex ps
ALLOWED_MIME_TYPES: application/pdf application/postscript application/illustrator image/x-eps image/svg+xml application/sla application/dxf application/acad application/dwg application/octet-stream application/step application/iges model/iges x-world/x-3dmf application/ application/vnd.openxmlformats-officedocument.wordprocessingml.document image/png text/x-arduino text/plain application/scad application/vnd.sketchup.skp application/x-koan application/vnd-koan koan/x-skm application/vnd.koan application/x-tex application/x-latex
# 10485760 = 10 megabytes
MAX_IMAGE_SIZE: 10485760

View File

@ -39,6 +39,7 @@ development:
log_level: <%= ENV["LOG_LEVEL"] %>
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
test:
secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
@ -69,6 +70,7 @@ test:
log_level: <%= ENV["LOG_LEVEL"] %>
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
elaticsearch_host: localhost
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
staging:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@ -104,6 +106,7 @@ staging:
log_level: <%= ENV["LOG_LEVEL"] %>
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
# Do not keep production secrets in the repository,
# instead read values from the environment.
@ -142,3 +145,4 @@ production:
log_level: <%= ENV["LOG_LEVEL"] %>
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>

View File

@ -60,3 +60,6 @@ LOG_LEVEL=debug
ALLOWED_EXTENSIONS=pdf ai eps cad math svg stl dxf dwg obj step iges igs 3dm 3dmf doc docx png ino scad fcad skp sldprt sldasm slddrw slddrt tex latex ps
ALLOWED_MIME_TYPES=application/pdf application/postscript application/illustrator image/x-eps image/svg+xml application/sla application/dxf application/acad application/dwg application/octet-stream application/step application/iges model/iges x-world/x-3dmf application/ application/vnd.openxmlformats-officedocument.wordprocessingml.document image/png text/x-arduino text/plain application/scad application/vnd.sketchup.skp application/x-koan application/vnd-koan koan/x-skm application/vnd.koan application/x-tex application/x-latex
# 10485760 = 10 megabytes
MAX_IMAGE_SIZE=10485760