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

N21-2106 Fix oauth school feature #3492

Merged
merged 6 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions controllers/administration.js
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ const getUsersWithoutConsent = async (req, roleName, classId) => {
.map((u) => u._id),
consentStatus: { $in: ['missing', 'parentsAgreed'] },
$limit: batchSize,
$sort: { 'lastName': 1},
$sort: { lastName: 1 },
},
})).data,
);
Expand Down Expand Up @@ -2260,6 +2260,8 @@ const schoolUpdateHandler = async (req, res, next) => {
name,
language,
logo_dataUrl,
rocketChat,
videoconference,
} = req.body;

let logo;
Expand All @@ -2270,14 +2272,28 @@ const schoolUpdateHandler = async (req, res, next) => {
};
}

const features = new Set(req.body.features);

if (rocketChat) {
features.add('rocketChat');
} else {
features.delete('rocketChat');
}

if (videoconference) {
features.add('videoconference');
} else {
features.delete('videoconference');
}

const requestBody = {
name,
language,
permissions: {
student: { LERNSTORE_VIEW: false },
teacher: { STUDENT_LIST: false },
},
features: [],
features: Array.from(features),
logo,
};

Expand All @@ -2293,17 +2309,6 @@ const schoolUpdateHandler = async (req, res, next) => {
requestBody.permissions.student.LERNSTORE_VIEW = !!req.body.studentlernstorevisibility;
}

// Update school features
const possibleSchoolFeatures = [
'messenger', 'messengerSchoolRoom', 'messengerStudentRoomCreate', 'rocketChat', 'videoconference',
];

for (const feature of possibleSchoolFeatures) {
if (req.body[feature] === 'true') {
requestBody.features.push(feature);
}
}

await api(req, { version: 'v3' }).patch(`/school/${res.locals.currentSchool}`, {
json: requestBody,
});
Expand Down
5 changes: 5 additions & 0 deletions views/administration/school.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@
</option>
{{/each}} </select> </div> {{/if}}
{{> "lib/components/csrfInput"}}

{{#each @root.school.features}}
<input type="hidden" name="features[]" value="{{this}}">
{{/each}}

<button type="submit" class="btn btn-primary btn-submit" data-testid="school-administration-save-general-setting">{{$t "administration.school.button.saveGeneralSettings" }}</button>
</form>

Expand Down
Loading