FEATURE: new 'poll_maximum_options' site setting to limit the number of options in a poll

This commit is contained in:
Régis Hanol
2015-05-01 16:44:51 +02:00
parent f83638c154
commit 2954c99a1e
4 changed files with 27 additions and 1 deletions

View File

@@ -231,6 +231,14 @@ after_initialize do
return
end
# maximum # of options
if poll["options"].size > SiteSetting.poll_maximum_options
poll["name"] == DEFAULT_POLL_NAME ?
self.errors.add(:base, I18n.t("poll.default_poll_must_have_less_options", max: SiteSetting.poll_maximum_options)) :
self.errors.add(:base, I18n.t("poll.named_poll_must_have_less_options", name: poll["name"], max: SiteSetting.poll_maximum_options))
return
end
# store the valid poll
polls[poll["name"]] = poll
end