mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: new 'poll_maximum_options' site setting to limit the number of options in a poll
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user