Skip to content

Commit

Permalink
Adding a way to cancel forfeiture
Browse files Browse the repository at this point in the history
  • Loading branch information
kristopolous committed Aug 24, 2017
1 parent cc560ba commit 542e807
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions modules/waivecar/controllers/bookings-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Bento.Register.Controller('BookingsController', function(controller) {
case 'complete' : return yield booking.complete(id, this.auth.user, this.query, this.payload);
case 'extend' : return yield booking.extend(id, this.auth.user);
case 'close' : return yield booking.close(id, this.auth.user);
case 'cancelforfeit' : return yield booking.cancelForfeit(id, this.auth.user);
default : {
throw error.parse({
code : `BOOKING_INVALID_ACTION`,
Expand Down
16 changes: 10 additions & 6 deletions modules/waivecar/lib/booking-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,16 @@ module.exports = class BookingService extends Service {
yield this.relay('update', booking, _user);
}

static *cancelForfeit(id, _user) {
let booking = yield this.getBooking(id);

if ( _user.hasAccess('admin')) {
yield booking.delForfeitureTimers();
yield booking.addFlag('cancelforfeit');
yield this.relay('update', booking, _user);
}
}

/*
|--------------------------------------------------------------------------------
| Delete Methods
Expand All @@ -860,12 +870,6 @@ module.exports = class BookingService extends Service {
|
*/

/**
* Attempts to cancel a booking.
* @param {Number} id
* @param {Object} _user
* @return {Object}
*/
static *cancel(id, _user) {
let booking = yield this.getBooking(id);
let car = yield this.getCar(booking.carId);
Expand Down

0 comments on commit 542e807

Please sign in to comment.