feat: cascade deletes, student notes, import popups, module reorganization
- Cascade delete on all entities (student, module, UE, user, role, promotion) - Fix Response body reuse bug (factory functions instead of constants) - Student note viewing via CAS uid (strip non-digit prefix) - Fix middleware page visibility for students in LOCAL mode - Import result popup component (shared across all import pages) - Fix student import to use numEtud from Excel - Bulk student selection with promo change and delete - Move UE/UE-Module API and pages from notes to admin module - Move promotions page from students to admin module - Multi-year maquette import with per-year promo selection - Inline promo creation in maquette import - Static Excel templates (students, notes, maquette) - Fix XLSX export using blob download instead of writeFile - Allow students to read modules list (GET /modules)
This commit is contained in:
@@ -41,7 +41,7 @@ export const handler: Handlers = {
|
||||
async POST(request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { note, numEtud, idModule } = body;
|
||||
const { note, numEtud, idModule, noteSession2 } = body;
|
||||
|
||||
if (note === undefined || !numEtud || !idModule) {
|
||||
return new Response("Champs 'note', 'numEtud' et 'idModule' requis", {
|
||||
@@ -55,7 +55,32 @@ export const handler: Handlers = {
|
||||
});
|
||||
}
|
||||
|
||||
const result = await db.insert(notes).values({ note, numEtud, idModule })
|
||||
if (
|
||||
noteSession2 !== undefined && noteSession2 !== null &&
|
||||
(typeof noteSession2 !== "number" || noteSession2 < 0 ||
|
||||
noteSession2 > 20)
|
||||
) {
|
||||
return new Response(
|
||||
"Champ 'noteSession2' doit être un nombre entre 0 et 20",
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
const values: {
|
||||
note: number;
|
||||
numEtud: number;
|
||||
idModule: string;
|
||||
noteSession2?: number | null;
|
||||
} = {
|
||||
note,
|
||||
numEtud,
|
||||
idModule,
|
||||
};
|
||||
if (noteSession2 !== undefined) {
|
||||
values.noteSession2 = noteSession2;
|
||||
}
|
||||
|
||||
const result = await db.insert(notes).values(values)
|
||||
.returning();
|
||||
|
||||
return new Response(JSON.stringify(result[0]), {
|
||||
|
||||
Reference in New Issue
Block a user