@@ -10,7 +10,7 @@ class Post < ApplicationRecord
10
10
validate :file_size
11
11
validate :validate_published_at
12
12
13
- enum status : { published : 0 , archived : 5 , draft : 10 , scheduled : 15 }
13
+ enum status : { published : 0 , archived : 5 , draft : 10 , scheduled : 15 , removed : 20 }
14
14
acts_as_ordered_taggable_on :tags
15
15
16
16
enum pin : { unpinned : 0 , pinned : 10 }
@@ -61,7 +61,7 @@ def correct_file_type
61
61
content_types = content . body . to_s . scan ( /content-type="(.*?)"/ )
62
62
63
63
content_types . each do |type |
64
- errors . add ( :content , 'Tipo de arquivo inválido.' ) unless options . include? type [ 0 ]
64
+ errors . add ( :content , I18n . t ( 'posts.model.invalid_file' ) ) unless options . include? type [ 0 ]
65
65
end
66
66
end
67
67
@@ -73,11 +73,11 @@ def file_size
73
73
74
74
def test_file_size ( attachments )
75
75
attachments . each do |attachment |
76
- validate_attachment_size ( attachment , 'image/png' , 2_000_000 , 'Tamanho de imagem permitido é 2mb' )
77
- validate_attachment_size ( attachment , 'image/jpeg' , 2_000_000 , 'Tamanho de imagem permitido é 2mb' )
78
- validate_attachment_size ( attachment , 'video/mp4' , 15_000_000 , 'Tamanho do vídeo permitido é 15mb' )
79
- validate_attachment_size ( attachment , 'audio/mpeg' , 3_000_000 , 'Tamanho do áudio permitido é 3mb' )
80
- validate_attachment_size ( attachment , 'application/pdf' , 900_000 , 'Tamanho do PDF permitido é 900kb' )
76
+ validate_attachment_size ( attachment , 'image/png' , 2_000_000 , I18n . t ( 'posts.model.max_image_size' ) )
77
+ validate_attachment_size ( attachment , 'image/jpeg' , 2_000_000 , I18n . t ( 'posts.model.max_image_size' ) )
78
+ validate_attachment_size ( attachment , 'video/mp4' , 15_000_000 , I18n . t ( 'posts.model.max_video_size' ) )
79
+ validate_attachment_size ( attachment , 'audio/mpeg' , 3_000_000 , I18n . t ( 'posts.model.max_audio_size' ) )
80
+ validate_attachment_size ( attachment , 'application/pdf' , 900_000 , I18n . t ( 'posts.model.max_pdf_size' ) )
81
81
end
82
82
end
83
83
@@ -89,7 +89,8 @@ def validate_attachment_size(attachment, content_type, size_limit, error_message
89
89
90
90
def validate_published_at
91
91
return if published_at . nil?
92
+ return unless scheduled?
92
93
93
- errors . add ( :published_at , 'não pode estar no passado' ) if published_at < ( Time . zone . now - 1 . second )
94
+ errors . add ( :published_at , I18n . t ( 'posts.model.invalid_date' ) ) if published_at < Time . zone . now
94
95
end
95
96
end
0 commit comments