1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 17:59:25 +00:00

Should not allow teachers to remove the last teacher from class

This commit is contained in:
2022-03-31 13:49:03 +00:00
parent 6a36fae78c
commit 0b09a9a61e
2 changed files with 17 additions and 2 deletions

View File

@@ -244,6 +244,11 @@ class Class {
if (!validTypes.includes(u.type))
throw new Error('Invalid user type');
this.teachers = await this.getTeachers();
if (u.type === 'account' && this.teachers.length < 2)
throw new Error('Can\'t remove last teacher');
const sql = `
delete from ${u.type}ClassLink
where