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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user