Created
August 25, 2014 22:13
-
-
Save antidiestro/a0d0e2a461ce3292b440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server | |
Votes.allow({ | |
insert: function (userId, vote){ | |
var voteCheck = Votes.findOne({user_id: userId, video_id: vote.video_id}); | |
if ( voteCheck ) { | |
return false; | |
} else { | |
if ( userId && vote.user_id === userId ) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
}, | |
remove: function(userId, vote){ | |
if ( userId && vote.user_id === userId ) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Template file | |
Template.roomPage.events({ | |
'click .proposed-videos-list li': function(){ | |
if ( !Meteor.userId() ) { | |
$('#loginModal').modal('show'); | |
return; | |
} | |
var voteCheck = Votes.findOne({user_id: Meteor.userId(), video_id: this._id}); | |
if ( voteCheck ) { | |
Votes.remove({_id: voteCheck._id}); | |
} else { | |
Votes.insert({user_id: Meteor.userId(), video_id: this._id}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment