add files validations to models
This commit is contained in:
parent
84c54f7271
commit
1f27652cd3
6 changed files with 39 additions and 7 deletions
|
@ -10,9 +10,8 @@ class AttestationTemplate < ApplicationRecord
|
|||
has_one_attached :signature
|
||||
|
||||
validates :footer, length: { maximum: 190 }
|
||||
|
||||
validates :logo, content_type: [:png, :jpg, :jpeg]
|
||||
validates :signature, content_type: [:png, :jpg, :jpeg]
|
||||
validates :logo, content_type: ['image/png', 'image/jpg', 'image/jpeg'], size: { less_than: 1.megabytes }
|
||||
validates :signature, content_type: ['image/png', 'image/jpg', 'image/jpeg'], size: { less_than: 1.megabytes }
|
||||
|
||||
DOSSIER_STATE = Dossier.states.fetch(:accepte)
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ class Avis < ApplicationRecord
|
|||
|
||||
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true
|
||||
validates :claimant, presence: true
|
||||
validates :piece_justificative_file, size: { less_than: 20.megabytes }
|
||||
validates :introduction_file, size: { less_than: 20.megabytes }
|
||||
|
||||
before_validation -> { sanitize_email(:email) }
|
||||
before_create :try_to_assign_instructeur
|
||||
|
|
|
@ -11,6 +11,7 @@ class Commentaire < ApplicationRecord
|
|||
has_one_attached :piece_jointe
|
||||
|
||||
validates :body, presence: { message: "ne peut être vide" }
|
||||
validates :piece_jointe, size: { less_than: 20.megabytes }
|
||||
|
||||
default_scope { order(created_at: :asc) }
|
||||
scope :updated_since?, -> (date) { where('commentaires.updated_at > ?', date) }
|
||||
|
|
|
@ -84,6 +84,26 @@ class Procedure < ApplicationRecord
|
|||
validates :duree_conservation_dossiers_dans_ds, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }, unless: :durees_conservation_required
|
||||
validates :duree_conservation_dossiers_hors_ds, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, unless: :durees_conservation_required
|
||||
validates_with MonAvisEmbedValidator
|
||||
validates :notice, content_type: [
|
||||
"application/msword",
|
||||
"application/pdf",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"application/vnd.ms-powerpoint",
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
"application/vnd.oasis.opendocument.text",
|
||||
"application/vnd.oasis.opendocument.presentation",
|
||||
"text/plain"
|
||||
], size: { less_than: 20.megabytes }
|
||||
|
||||
validates :deliberation, content_type: [
|
||||
"application/msword",
|
||||
"application/pdf",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"text/plain",
|
||||
"application/vnd.oasis.opendocument.text"
|
||||
], size: { less_than: 20.megabytes }
|
||||
|
||||
validates :logo, content_type: ['image/png', 'image/jpg', 'image/jpeg'], size: { less_than: 5.megabytes }
|
||||
before_save :update_juridique_required
|
||||
before_save :update_durees_conservation_required
|
||||
after_initialize :ensure_path_exists
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue