Skip to content

Commit

Permalink
Working again. Yay.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Peabody committed Feb 13, 2011
1 parent a15c0df commit e2476cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ app.get('/', function(req, res){

app.post("/up", function(req, res){
if (req.body.id) {
Movie.find({_id:req.body.id, is3D:1}).first(function(movie){
Movie.findById(req.body.id, function(err, movie){
movie.up_count++;
movie.save();
res.send({status: 200, movie:movie});
Expand All @@ -62,7 +62,7 @@ app.post("/up", function(req, res){

app.post("/down", function(req, res){
if (req.body.id) {
Movie.find({_id:req.body.id, is3D:1}).first(function(movie){
Movie.findById(req.body.id, function(err, movie){
movie.down_count++;
movie.save();
res.send({status: 200, movie:movie});
Expand Down
3 changes: 1 addition & 2 deletions lib/movies.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ exports.load = function(){
, isActiveForVoting : { type: Number, default: 0 }
});
mongoose.model('Movie', Movie);
}

};
6 changes: 3 additions & 3 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ $(function(){
$(".up").live("click",function(){
var sender = $(this);
$.post("/up", {id:sender.attr("data-id")}, function(resp){
var movie = JSON.parse(resp.movie);
var movie = resp.movie;
sender.html(":) "+ movie.up_count);
});
});
$(".down").live("click",function(){
var sender = $(this);
$.post("/down", {id:sender.attr("data-id")}, function(resp){
var movie = JSON.parse(resp.movie);
sender.html(":) "+ movie.down_count);
var movie = resp.movie;
sender.html(":( "+ movie.down_count);
});
});
});
4 changes: 2 additions & 2 deletions views/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ p Is it worth seeing in 3D?
- each movie in movies
.movie
.title= movie.title
.up('data-id':movie.key) :) #{movie.up_count}
.down('data-id':movie.key) :( #{movie.down_count}
.up('data-id':movie._id) :) #{movie.up_count}
.down('data-id':movie._id) :( #{movie.down_count}

0 comments on commit e2476cd

Please sign in to comment.