Created
May 26, 2013 20:27
-
-
Save bplexico/5653913 to your computer and use it in GitHub Desktop.
Before refactoring Post to remove duplication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure maximum amount of mentions in a post | |
def max_mention_validator | |
if acting_user.present? && acting_user.has_trust_level?(:basic) | |
errors.add(:base, I18n.t(:too_many_mentions, count: SiteSetting.max_mentions_per_post)) if raw_mentions.size > SiteSetting.max_mentions_per_post | |
else | |
errors.add(:base, I18n.t(:too_many_mentions_newuser, count: SiteSetting.newuser_max_mentions_per_post)) if raw_mentions.size > SiteSetting.newuser_max_mentions_per_post | |
end | |
end | |
# Ensure new users can not put too many images in a post | |
def max_images_validator | |
return if acting_user.present? && acting_user.has_trust_level?(:basic) | |
errors.add(:base, I18n.t(:too_many_images, count: SiteSetting.newuser_max_images)) if image_count > SiteSetting.newuser_max_images | |
end | |
# Ensure new users can not put too many links in a post | |
def max_links_validator | |
return if acting_user.present? && acting_user.has_trust_level?(:basic) | |
errors.add(:base, I18n.t(:too_many_links, count: SiteSetting.newuser_max_links)) if link_count > SiteSetting.newuser_max_links | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment