add newuser-max-attachments setting

This commit is contained in:
Régis Hanol
2013-07-22 02:39:17 +02:00
parent 33e3f123b4
commit 2986798ba7
13 changed files with 120 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ class Validators::PostValidator < ActiveModel::Validator
raw_quality(record)
max_mention_validator(record)
max_images_validator(record)
max_attachments_validator(record)
max_links_validator(record)
unique_post_validator(record)
end
@@ -41,6 +42,11 @@ class Validators::PostValidator < ActiveModel::Validator
add_error_if_count_exceeded(post, :too_many_images, post.image_count, SiteSetting.newuser_max_images) unless acting_user_is_trusted?(post)
end
# Ensure new users can not put too many attachments in a post
def max_attachments_validator(post)
add_error_if_count_exceeded(post, :too_many_attachments, post.attachment_count, SiteSetting.newuser_max_attachments) unless acting_user_is_trusted?(post)
end
# Ensure new users can not put too many links in a post
def max_links_validator(post)
add_error_if_count_exceeded(post, :too_many_links, post.link_count, SiteSetting.newuser_max_links) unless acting_user_is_trusted?(post)