Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/LizaHCarter/wine-seller i…
Browse files Browse the repository at this point in the history
…nto sortsearchfilter

Enhanced Bidding functionality & views
  • Loading branch information
abarnhard committed Aug 31, 2014
2 parents e30aeab + 231e7f6 commit c6fb901
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
11 changes: 8 additions & 3 deletions app/controllers/bids.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ var Bid = require('../models/bid');

exports.create = function(req, res){
// console.log('********REQ BODY', req.body);
Bid.create(req.body, req.params.itemOfferedId, function(){
res.redirect('/marketplace');
});
console.log('Res.locals Id' + res.locals.user._id, 'Req.body' + req.body.upForBidOwnerId);
if (res.locals.user._id.toString() !== req.body.upForBidOwnerId.toString()){
Bid.create(req.body, req.params.itemOfferedId, function(){
res.redirect('/marketplace');
});
}else{
res.redirect('/');
}
};
7 changes: 7 additions & 0 deletions app/views/items/show-bid.jade
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ block content
td: a(href='/bid/#{item._id}')= item.name
td= item.location
td= item.description
if user._id.toString() === item.ownerId.toString()
.row
.col-xs-12
p This is your item.
else
.row
.col-xs-12
#bids
Expand All @@ -31,6 +36,8 @@ block content
input(type='hidden', name='offerOwnerId', value=bidItem.ownerId)
input(type='hidden', name='upForBidOwnerId', value=item.ownerId)
button#bidButton.btn.btn-success(type='submit') Bid It


block scripts
script(src='/js/user/items-index.js')

23 changes: 18 additions & 5 deletions app/views/users/message.jade
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
extends ../shared/template
block content
h2 Message from:
h3= msg.sender.name
h4
p Date : #{msg.date.toDateString()}
p Body : #{msg.message}
.row
.col-xs-1
.col-xs-8
h3 Message from #{msg.sender.name}
.panel.panel-default
.panel-body
p Date : #{msg.date.toDateString()}
h4 #{msg.message}
.col-xs-2
a.thumbnail(href='#')
img(src=msg.sender.photo)
.col-xs-1
.row
.col-xs-1

.col-xs-3
button.btn.btn-primary: a(href='/users/#{msg.sender.email}') Reply to #{msg.sender.name}


block scripts
12 changes: 11 additions & 1 deletion test/acceptance/bids.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ describe('users', function(){
done();
});
});
it('should redirect to home if user owns item', function(done){
request(app)
.post('/bidding/a00000000000000000000001')
.set('cookie', cookie)
.send('itemUpForBidId=a00000000000000000000002&itemOfferedId=a00000000000000000000001&offerOwnerId=000000000000000000000001&upForBidOwnerId=000000000000000000000001')
.end(function(err, res){
expect(res.status).to.equal(302);
expect(res.headers.location).to.equal('/');
done();
});
});
});

});

0 comments on commit c6fb901

Please sign in to comment.