Skip to content

Commit 3cd7851

Browse files
committed
Made snippit voter user details available on client-side
1 parent 91dbda8 commit 3cd7851

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

app/views/partials/main.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ <h3>Results:</h3>
9595
<div class="row">
9696
<pre class="col-md-10" ng-click="openModal('lg', snippitObj)" >{{snippitObj.snippit}}</pre>
9797
<div class="col-md-2">
98-
<i class="glyphicon glyphicon-thumbs-up" ng-click="snippitVote(1, snippitObj)"></i>
98+
<i class="glyphicon glyphicon-thumbs-up" ng-click="snippitVote(1, snippitObj, $index)" ng-hide="snippitObj.snippitVoters[currentUser.github_id] === 1"></i>
9999
{{snippitObj.snippitScore}}
100-
<i class="glyphicon glyphicon-thumbs-down" ng-click="snippitVote(-1, snippitObj)"></i>
100+
<i class="glyphicon glyphicon-thumbs-down" ng-click="snippitVote(-1, snippitObj, $index)" ng-hide="snippitObj.snippitVoters[currentUser.github_id] === -1"></i>
101101
<p ng-show="notSignedIn">Please sign in to vote</p>
102102
</div>
103103
</div>

lib/controllers/files.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,13 @@ exports.findCode = function(req, res, next) {
162162
for (var i = 0; i < file._snippitIds.length; i++){
163163
if (snippitObj.snippit === file._snippitIds[i].snippit) {
164164
snippitObj.snippitScore = file._snippitIds[i].score;
165+
snippitObj.snippitVoters = file._snippitIds[i].github_id;
165166
}
166167
}
167168
}
168169
if (!snippitObj.snippitScore) {
169170
snippitObj.snippitScore = 0;
171+
snippitObj.snippitVoters = null;
170172
}
171173
returnArr.push(snippitObj);
172174
});

lib/controllers/voting.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ var Snippit = mongoose.model('Snippit');
33
var File = mongoose.model('File');
44

55
exports.snippitVote = function(req, res, next) {
6-
// var githubId = req.user.github_id // fix later
7-
var githubId = 5555;
6+
var githubId = req.user.github_id;
87
var votePref = req.body.votePreference;
98
var snippit = req.body.snippit;
109
var filePath = req.body.filePath;

0 commit comments

Comments
 (0)