• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GrottoCenter / grottocenter-api / 11210769896

07 Oct 2024 07:32AM UTC coverage: 46.184% (+0.08%) from 46.105%
11210769896

push

github

vmarseguerra
fix(entities): small issues
- document description body is not saved when importing a csv
- cannot get statistics for country and massif
- broken sql dev setup
- missing 'names' key in massif converter
- stop validating the mimeType when uploading a file

740 of 2199 branches covered (33.65%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 3 files covered. (0.0%)

251 existing lines in 21 files now uncovered.

2485 of 4784 relevant lines covered (51.94%)

4.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.0
/api/controllers/v1/location/delete.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const NotificationService = require('../../../services/NotificationService');
1✔
3
const LocationService = require('../../../services/LocationService');
1✔
4
const { toSimpleLocation } = require('../../../services/mapping/converters');
1✔
5
const RightService = require('../../../services/RightService');
1✔
6
const RecentChangeService = require('../../../services/RecentChangeService');
1✔
7

8
module.exports = async (req, res) => {
1✔
UNCOV
9
  const hasRight = RightService.hasGroup(
×
10
    req.token.groups,
11
    RightService.G.MODERATOR
12
  );
13
  if (!hasRight)
×
UNCOV
14
    return res.forbidden('You are not authorized to delete location.');
×
15

16
  const locationId = req.param('id');
×
17
  const location = await LocationService.getLocation(locationId);
×
18
  if (!location) {
×
UNCOV
19
    return res.notFound({ message: `Location of id ${locationId} not found.` });
×
20
  }
21

22
  if (!location.isDeleted) {
×
23
    await TLocation.destroyOne({ id: locationId }); // Soft delete
×
UNCOV
24
    location.isDeleted = true;
×
25

26
    await RecentChangeService.setDeleteRestoreAuthor(
×
27
      'delete',
28
      'location',
29
      locationId,
30
      req.token.id
31
    );
32
  }
33

UNCOV
34
  const deletePermanently = !!req.param('isPermanent');
×
UNCOV
35
  if (deletePermanently) {
×
UNCOV
36
    await HLocation.destroy({ t_id: locationId });
×
UNCOV
37
    await TNotification.destroy({ location: locationId });
×
UNCOV
38
    await TLocation.destroyOne({ id: locationId }); // Hard delete
×
39
  }
40

UNCOV
41
  await NotificationService.notifySubscribers(
×
42
    req,
43
    location,
44
    req.token.id,
45
    deletePermanently
×
46
      ? NotificationService.NOTIFICATION_TYPES.PERMANENT_DELETE
47
      : NotificationService.NOTIFICATION_TYPES.DELETE,
48
    NotificationService.NOTIFICATION_ENTITIES.LOCATION
49
  );
50

UNCOV
51
  return ControllerService.treatAndConvert(
×
52
    req,
53
    null,
54
    location,
55
    { controllerMethod: 'LocationController.delete' },
56
    res,
57
    toSimpleLocation
58
  );
59
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc