Gems are now refunded to challenge leader on deletion. Needs better description in "broken" field.

This commit is contained in:
NotGonnaGitUs
2015-05-04 02:33:59 +05:30
parent 0454938303
commit 46cb0240c3
2 changed files with 14 additions and 3 deletions

View File

@@ -1,9 +1,11 @@
<a name="">My app - Changelog</a> <a name="">My app - Changelog</a>
# (2015-05-02) # (2015-05-04)
## Bug Fixes ## Bug Fixes
- **Spring:** WHO IS LESLIE
([6685e935](watch/commits/6685e93554a1274dedb55dae054e787fb80eb440))
- **invite-friends:** text should be valid for both parties and guilds - **invite-friends:** text should be valid for both parties and guilds
([54e82a14](watch/commits/54e82a14a252c3b9923449a7ef7cee6033a5d160)) ([54e82a14](watch/commits/54e82a14a252c3b9923449a7ef7cee6033a5d160))
- **mystery:** It's 2015 now, Sabe - **mystery:** It's 2015 now, Sabe
@@ -16,6 +18,8 @@
## Features ## Features
- **Spring:** Flung
([d50d4ad8](watch/commits/d50d4ad8bb0f89e39ceb6562e0f8f392f94b5444))
- **emails:** add support for weekly recap emails - **emails:** add support for weekly recap emails
([37f7db3c](watch/commits/37f7db3c4e3859d03fd55a44e63819e273a06442)) ([37f7db3c](watch/commits/37f7db3c4e3859d03fd55a44e63819e273a06442))
- **i18n:** upload japanese, serbian and chinese (taiwan) - **i18n:** upload japanese, serbian and chinese (taiwan)

View File

@@ -300,14 +300,21 @@ function closeChal(cid, broken, cb) {
api['delete'] = function(req, res, next){ api['delete'] = function(req, res, next){
var user = res.locals.user; var user = res.locals.user;
var cid = req.params.cid; var cid = req.params.cid;
var chal
async.waterfall([ async.waterfall([
function(cb){ function(cb){
Challenge.findById(cid, cb); Challenge.findById(cid, cb);
}, },
function(chal, cb){ function(_chal, cb){
chal = _chal;
if (!chal) return cb('Challenge ' + cid + ' not found'); if (!chal) return cb('Challenge ' + cid + ' not found');
if (chal.leader != user._id) return cb("You don't have permissions to edit this challenge"); if (chal.leader != user._id) return cb("You don't have permissions to edit this challenge");
closeChal(req.params.cid, {broken: 'CHALLENGE_DELETED'}, cb); User.findById(user._id, cb) //Refunds to challenge leader
},
function(leader, cb){
leader.balance += chal.prize/4;
leader.save(cb);
closeChal(req.params.cid, {broken: 'CHALLENGE_DELETED'}, cb); //Not descriptive enough
} }
], function(err){ ], function(err){
if (err) return next(err); if (err) return next(err);