Skip to content

Commit

Permalink
add (insecure) voting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rayman committed Nov 28, 2014
1 parent 8468dfc commit ddac089
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion both/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/views/radios/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>{{title}}</h1>
{{/each}}
</div>
<div class="col-md-1">
<button><span class="glyphicon glyphicon-chevron-up"></span></button>
<button data-action="voteup"><span class="glyphicon glyphicon-chevron-up"></span></button>
</div>
</div>
</template>
11 changes: 11 additions & 0 deletions client/views/radios/radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()} }
);
}
});

0 comments on commit ddac089

Please sign in to comment.