From ddac089cd6735d9c8536ce2fba013a87596c9e12 Mon Sep 17 00:00:00 2001 From: Ramon Wijnands Date: Fri, 28 Nov 2014 17:37:10 +0000 Subject: [PATCH] add (insecure) voting --- both/collections.js | 3 ++- client/views/radios/radio.html | 2 +- client/views/radios/radio.js | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/both/collections.js b/both/collections.js index bf975f1..ede2a78 100644 --- a/both/collections.js +++ b/both/collections.js @@ -268,7 +268,8 @@ RadioSongSchema = new SimpleSchema({ } else if (this.isUpsert) { return { $setOnInsert: [this.userId] }; } else { - this.unset(); + // figure out if this is allowed or not :D + return; } } } diff --git a/client/views/radios/radio.html b/client/views/radios/radio.html index a1a1a4e..57d329e 100644 --- a/client/views/radios/radio.html +++ b/client/views/radios/radio.html @@ -29,7 +29,7 @@

{{title}}

{{/each}}
- +
diff --git a/client/views/radios/radio.js b/client/views/radios/radio.js index 03f13ea..3fa0147 100644 --- a/client/views/radios/radio.js +++ b/client/views/radios/radio.js @@ -15,3 +15,14 @@ Template.radio.helpers({ return radioSongs; }, }); + +Template.radioSong.events({ + 'click [data-action="voteup"]': function (e, template) { + var id = template.data._id; + console.log('voting for', id); + RadioSongs.update( + { _id: id }, + { $addToSet : {'votes': Meteor.userId()} } + ); + } +});