Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change users/admin get routes to v3 #3417

Merged
merged 13 commits into from
Mar 18, 2024
13 changes: 7 additions & 6 deletions controllers/administration.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ router.get(
'/teachers/:id/edit',
permissionsHelper.permissionsChecker(['ADMIN_VIEW', 'TEACHER_EDIT'], 'or'),
(req, res, next) => {
const userPromise = api(req).get(`users/admin/teachers/${req.params.id}`);
const userPromise = api(req, { version: 'v3' }).get(`users/admin/teachers/${req.params.id}`);
const classesPromise = getSelectOptions(req, 'classes', {
$populate: ['year'],
$sort: 'displayName',
Expand Down Expand Up @@ -1119,7 +1119,7 @@ router.get(
'/students/:id/skipregistration',
permissionsHelper.permissionsChecker('STUDENT_SKIP_REGISTRATION'),
(req, res, next) => {
api(req).get(`/users/admin/students/${req.params.id}`)
api(req, { version: 'v3' }).get(`/users/admin/students/${req.params.id}`)
.then((user) => {
res.render('administration/users_skipregistration', {
title: res.$t('administration.controller.link.toGiveConsent'),
Expand Down Expand Up @@ -1165,7 +1165,7 @@ router.get(
$skip: itemsPerPage * (currentPage - 1),
};
query = Object.assign(query, filterQuery);
api(req)
api(req, { version: 'v3' })
.get('/users/admin/students', {
qs: query,
})
Expand Down Expand Up @@ -1288,13 +1288,14 @@ const getUsersWithoutConsent = async (req, roleName, classId) => {
const batchSize = 50;
while (users.length > 0) {
usersWithMissingConsents.push(
...(await api(req).get('/users/admin/students', {
...(await api(req, { version: 'v3' }).get('/users/admin/students', {
qs: {
users: users
.splice(0, batchSize)
.map((u) => u._id),
consentStatus: ['missing', 'parentsAgreed'],
consentStatus: { $in: ['missing', 'parentsAgreed'] },
$limit: batchSize,
$sort: { 'lastName': 1},
},
})).data,
);
Expand Down Expand Up @@ -1400,7 +1401,7 @@ router.get(
'/students/:id/edit',
permissionsHelper.permissionsChecker(['ADMIN_VIEW', 'STUDENT_EDIT'], 'or'),
(req, res, next) => {
const userPromise = api(req).get(`/users/admin/students/${req.params.id}`);
const userPromise = api(req, { version: 'v3' }).get(`/users/admin/students/${req.params.id}`);
const accountPromise = api(req, { json: true, version: 'v3' })
.get('/account', {
qs: { type: 'userId', value: req.params.id },
Expand Down
Loading