Merge pull request #2214 from vikhyat/poll-plugin
Make polls work better on multi-language forums
This commit is contained in:
commit
524e469693
|
@ -33,7 +33,7 @@ after_initialize do
|
||||||
|
|
||||||
post = Post.find(params[:post_id])
|
post = Post.find(params[:post_id])
|
||||||
poll = PollPlugin::Poll.new(post)
|
poll = PollPlugin::Poll.new(post)
|
||||||
unless poll.is_poll?
|
unless poll.has_poll_details?
|
||||||
render status: 400, json: false
|
render status: 400, json: false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -102,7 +102,7 @@ after_initialize do
|
||||||
PollPlugin::Poll.new(object).serialize(scope.user)
|
PollPlugin::Poll.new(object).serialize(scope.user)
|
||||||
end
|
end
|
||||||
def include_poll_details?
|
def include_poll_details?
|
||||||
PollPlugin::Poll.new(object).is_poll?
|
PollPlugin::Poll.new(object).has_poll_details?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,6 +24,18 @@ module ::PollPlugin
|
||||||
topic.title =~ /^#{I18n.t('poll.prefix')}/i
|
topic.title =~ /^#{I18n.t('poll.prefix')}/i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_poll_details?
|
||||||
|
if SiteSetting.allow_user_locale?
|
||||||
|
# If we allow users to select their locale of choice we cannot detect polls
|
||||||
|
# by the prefix, so we fall back to checking if the poll details is set in
|
||||||
|
# places to make sure polls are still accessible by users using a different
|
||||||
|
# locale than the one used by the topic creator.
|
||||||
|
not self.details.nil?
|
||||||
|
else
|
||||||
|
self.is_poll?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Called during validation of poll posts. Discourse already restricts edits to
|
# Called during validation of poll posts. Discourse already restricts edits to
|
||||||
# the OP and staff, we want to make sure that:
|
# the OP and staff, we want to make sure that:
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue