changed default 'poll maximum options' to 20

This commit is contained in:
Régis Hanol 2015-05-19 14:33:27 +02:00
parent efb992c9d9
commit d889f05480
2 changed files with 6 additions and 5 deletions

View File

@ -2,4 +2,4 @@ plugins:
poll_enabled: poll_enabled:
default: true default: true
poll_maximum_options: poll_maximum_options:
default: 10 default: 20

View File

@ -40,15 +40,16 @@ task "poll:migrate_old_polls" => :environment do
next if post.custom_fields.include?("polls") next if post.custom_fields.include?("polls")
# go back in time # go back in time
Timecop.freeze(post.created_at + 1.minute) do Timecop.freeze(post.created_at + 1.minute) do
post.raw = post.raw.gsub(/\n\n([ ]*[-\*\+] )/, "\n\\1") + "\n\n" raw = post.raw.gsub(/\n\n([ ]*[-\*\+] )/, "\n\\1") + "\n\n"
# fix the RAW when needed # fix the RAW when needed
if post.raw !~ /\[poll\]/ if raw !~ /\[poll\]/
lists = /^[ ]*[-\*\+] .+?$\n\n/m.match(post.raw) lists = /^[ ]*[-\*\+] .+?$\n\n/m.match(raw)
next if lists.blank? || lists.length == 0 next if lists.blank? || lists.length == 0
first_list = lists[0] first_list = lists[0]
post.raw = post.raw.sub(first_list, "\n[poll]\n#{first_list}\n[/poll]\n") raw = raw.sub(first_list, "\n[poll]\n#{first_list}\n[/poll]\n")
end end
# save the poll # save the poll
post.raw = raw
post.save post.save
# make sure we have a poll # make sure we have a poll
next if post.custom_fields.blank? || !post.custom_fields.include?("polls") next if post.custom_fields.blank? || !post.custom_fields.include?("polls")