Fix delete endpoint - remove associated wars
parent
dbca2a3d93
commit
947e8df1f7
|
@ -13,6 +13,8 @@ const checkMT = require('../middleware/permission-check').checkMT;
|
||||||
|
|
||||||
// Mongoose Model using mongoDB
|
// Mongoose Model using mongoDB
|
||||||
const CampaignModel = require('../models/campaign');
|
const CampaignModel = require('../models/campaign');
|
||||||
|
const WarModel = require('../models/war');
|
||||||
|
|
||||||
|
|
||||||
const campaigns = express.Router();
|
const campaigns = express.Router();
|
||||||
|
|
||||||
|
@ -66,7 +68,10 @@ campaigns.route('/:id')
|
||||||
err.status = codes.notfound;
|
err.status = codes.notfound;
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
return next();
|
WarModel.find({campaign: req.params.id}).remove().exec();
|
||||||
|
|
||||||
|
res.locals.processed = true;
|
||||||
|
next();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
id="campaign"
|
id="campaign"
|
||||||
[(ngModel)]="war.campaign"
|
[(ngModel)]="war.campaign"
|
||||||
required>
|
required>
|
||||||
<option *ngFor="let campaign of warService.campaigns" [ngValue]="campaign._id">
|
<option *ngFor="let campaign of campaignService.campaigns" [ngValue]="campaign._id">
|
||||||
{{campaign.title}}
|
{{campaign.title}}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {WarService} from "../../services/war-service/war.service";
|
import {WarService} from "../../services/war-service/war.service";
|
||||||
import {War} from "../../models/model-interfaces";
|
import {War} from "../../models/model-interfaces";
|
||||||
|
import {CampaignService} from "../../services/campaign-service/campaign.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -28,7 +29,8 @@ export class WarSubmitComponent {
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private warService: WarService) {
|
private warService: WarService,
|
||||||
|
private campaignService: CampaignService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fileChange(event) {
|
fileChange(event) {
|
||||||
|
|
Loading…
Reference in New Issue