commit 876e3c8fc6de50c830a48df82d00ed180b38384b
parent 3096def39d8e7a088270f761739e8cba9a76d909
Author: Fredrik <moi@knutsen.co>
Date: Sat, 17 Nov 2018 14:14:08 +0000
Merge pull request #16 from Demonstrandum/devel
Don't accept alternative votes is 'alt' is set to true (server side).
Diffstat:
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/public/poller.js b/public/poller.js
@@ -156,7 +156,7 @@ $('document').ready(() => {
},
error: e => {
issue(ISSUE.FATAL, `
- An erro occured while casting your vote.\n
+ An error occurred while casting your vote.\n
More Information:\n
${e}
`);
diff --git a/server.rb b/server.rb
@@ -111,9 +111,9 @@ post '/poll/:poll/cast' do
return nil if request.ip != '::1' && POLLS.find(:"$and" => [{:code => params[:poll]}, {:voters => request.ip}]).to_a.size > 0
POLLS.update_one({:code => params[:poll]}, {:"$push" => {:voters => request.ip}}) unless request.ip == '::1'
- if POLLS.find({ :"votes.#{params[:vote]}" => {"$exists": true} }).to_a.size > 0
+ if POLLS.find({ :"$and" => [{:code => params[:poll]}, { :"votes.#{params[:vote]}" => {"$exists": true}}] }).to_a.size > 0
POLLS.update_one({:code => params[:poll]}, { :"$inc" => { :"votes.#{params[:vote]}.number" => 1 } })
- else
+ elsif POLLS.find({:code => params[:poll]}).first[:alt]
POLLS.update_one({:code => params[:poll]}, { :"$set" => { :"votes.#{params[:vote]}" => {
:number => 1,
:primary => false,
diff --git a/views/poll.erb b/views/poll.erb
@@ -12,7 +12,7 @@
</script>
<style>
.others {
- display: none;
+ display: none !important;
}
</style>
<% end %>
@@ -162,7 +162,6 @@
for (let mono = range.min; mono <= range.max; mono += range.max / (N + 1))
backgrounds[Math.round((mono - range.min) * N / range.max)] = `rgba(0,0,0,${mono})`;
chart.data.datasets[0].backgroundColor = backgrounds;
- console.log(backgrounds);
return backgrounds;
};