|
|
@ -15,6 +15,7 @@ module Forms |
|
|
|
|
|
|
|
|
|
|
|
validates :file, presence: true |
|
|
|
validates :file, presence: true |
|
|
|
validate :validate_file_is_csv |
|
|
|
validate :validate_file_is_csv |
|
|
|
|
|
|
|
validate :validate_file_size |
|
|
|
|
|
|
|
|
|
|
|
def view_path |
|
|
|
def view_path |
|
|
|
"bulk_upload_lettings_logs/forms/upload_your_file" |
|
|
|
"bulk_upload_lettings_logs/forms/upload_your_file" |
|
|
@ -73,6 +74,16 @@ module Forms |
|
|
|
errors.add(:file, :not_csv) |
|
|
|
errors.add(:file, :not_csv) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MAX_FILE_SIZE = 10.megabytes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_file_size |
|
|
|
|
|
|
|
return unless file |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if file.size > MAX_FILE_SIZE |
|
|
|
|
|
|
|
errors.add(:file, :file_too_large) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|