Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f59589bb28 |
+10
-9
@@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
date,
|
date,
|
||||||
doublePrecision,
|
|
||||||
integer,
|
integer,
|
||||||
pgTable,
|
pgTable,
|
||||||
primaryKey,
|
primaryKey,
|
||||||
|
real,
|
||||||
serial,
|
serial,
|
||||||
text,
|
text,
|
||||||
} from "npm:drizzle-orm/pg-core";
|
} from "npm:drizzle-orm/pg-core";
|
||||||
@@ -33,15 +33,16 @@ export const users = pgTable("users", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const promotions = pgTable("promotions", {
|
export const promotions = pgTable("promotions", {
|
||||||
id: text("idPromo").primaryKey(),
|
id: serial("id").primaryKey(),
|
||||||
annee: text("annee"),
|
endyear: integer("endyear"),
|
||||||
|
current: integer("current"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const students = pgTable("students", {
|
export const students = pgTable("students", {
|
||||||
numEtud: serial("numEtud").primaryKey(),
|
numEtud: serial("numEtud").primaryKey(),
|
||||||
nom: text("nom").notNull(),
|
nom: text("nom").notNull(),
|
||||||
prenom: text("prenom").notNull(),
|
prenom: text("prenom").notNull(),
|
||||||
idPromo: text("idPromo").references(() => promotions.id),
|
idPromo: text("idPromo").references(() => promotions.id as unknown as string),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const modules = pgTable("modules", {
|
export const modules = pgTable("modules", {
|
||||||
@@ -52,7 +53,7 @@ export const modules = pgTable("modules", {
|
|||||||
export const enseignements = pgTable("enseignements", {
|
export const enseignements = pgTable("enseignements", {
|
||||||
idProf: text("idProf").notNull().references(() => users.id),
|
idProf: text("idProf").notNull().references(() => users.id),
|
||||||
idModule: text("idModule").notNull().references(() => modules.id),
|
idModule: text("idModule").notNull().references(() => modules.id),
|
||||||
idPromo: text("idPromo").notNull().references(() => promotions.id),
|
idPromo: text("idPromo").notNull(),
|
||||||
}, (t) => ({
|
}, (t) => ({
|
||||||
pk: primaryKey({ columns: [t.idProf, t.idModule, t.idPromo] }),
|
pk: primaryKey({ columns: [t.idProf, t.idModule, t.idPromo] }),
|
||||||
}));
|
}));
|
||||||
@@ -65,8 +66,8 @@ export const ues = pgTable("ues", {
|
|||||||
export const ueModules = pgTable("ue_modules", {
|
export const ueModules = pgTable("ue_modules", {
|
||||||
idModule: text("idModule").notNull().references(() => modules.id),
|
idModule: text("idModule").notNull().references(() => modules.id),
|
||||||
idUE: integer("idUE").notNull().references(() => ues.id),
|
idUE: integer("idUE").notNull().references(() => ues.id),
|
||||||
idPromo: text("idPromo").notNull().references(() => promotions.id),
|
idPromo: text("idPromo").notNull(),
|
||||||
coeff: doublePrecision("coeff").notNull(),
|
coeff: real("coeff").notNull(),
|
||||||
}, (t) => ({
|
}, (t) => ({
|
||||||
pk: primaryKey({ columns: [t.idModule, t.idUE, t.idPromo] }),
|
pk: primaryKey({ columns: [t.idModule, t.idUE, t.idPromo] }),
|
||||||
}));
|
}));
|
||||||
@@ -74,7 +75,7 @@ export const ueModules = pgTable("ue_modules", {
|
|||||||
export const notes = pgTable("notes", {
|
export const notes = pgTable("notes", {
|
||||||
numEtud: integer("numEtud").notNull().references(() => students.numEtud),
|
numEtud: integer("numEtud").notNull().references(() => students.numEtud),
|
||||||
idModule: text("idModule").notNull().references(() => modules.id),
|
idModule: text("idModule").notNull().references(() => modules.id),
|
||||||
note: doublePrecision("note").notNull(),
|
note: real("note").notNull(),
|
||||||
}, (t) => ({
|
}, (t) => ({
|
||||||
pk: primaryKey({ columns: [t.numEtud, t.idModule] }),
|
pk: primaryKey({ columns: [t.numEtud, t.idModule] }),
|
||||||
}));
|
}));
|
||||||
@@ -82,7 +83,7 @@ export const notes = pgTable("notes", {
|
|||||||
export const ajustements = pgTable("ajustements", {
|
export const ajustements = pgTable("ajustements", {
|
||||||
numEtud: integer("numEtud").notNull().references(() => students.numEtud),
|
numEtud: integer("numEtud").notNull().references(() => students.numEtud),
|
||||||
idUE: integer("idUE").notNull().references(() => ues.id),
|
idUE: integer("idUE").notNull().references(() => ues.id),
|
||||||
valeur: doublePrecision("valeur").notNull(),
|
valeur: real("valeur").notNull(),
|
||||||
}, (t) => ({
|
}, (t) => ({
|
||||||
pk: primaryKey({ columns: [t.numEtud, t.idUE] }),
|
pk: primaryKey({ columns: [t.numEtud, t.idUE] }),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
import { AppProperties } from "$root/defaults/interfaces.ts";
|
|
||||||
|
|
||||||
const properties: AppProperties = {
|
|
||||||
name: "Admin",
|
|
||||||
icon: "school",
|
|
||||||
pages: {
|
|
||||||
index: "Homepage",
|
|
||||||
},
|
|
||||||
adminOnly: [],
|
|
||||||
hint: "PolyMPR module",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default properties;
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import { Handlers } from "$fresh/server.ts";
|
|
||||||
|
|
||||||
export const handler: Handlers = {
|
|
||||||
async POST(request, context) {
|
|
||||||
if (request.headers.get("content-type") != "application/json") {
|
|
||||||
return new Response(null, {
|
|
||||||
status: 400,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const responseBody = {
|
|
||||||
requestBody: await request.json(),
|
|
||||||
context,
|
|
||||||
};
|
|
||||||
|
|
||||||
return new Response(JSON.stringify(responseBody), {
|
|
||||||
headers: {
|
|
||||||
"content-type": "application/json",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import { Handlers } from "$fresh/server.ts";
|
|
||||||
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
|
|
||||||
|
|
||||||
const PERMISSIONS = [
|
|
||||||
{ id: "student_read", nom: "Consulter les élèves" },
|
|
||||||
{ id: "student_write", nom: "Gérer les élèves" },
|
|
||||||
{ id: "note_read", nom: "Consulter les notes" },
|
|
||||||
{ id: "note_write", nom: "Gérer les notes" },
|
|
||||||
{ id: "module_read", nom: "Consulter les modules" },
|
|
||||||
{ id: "module_write", nom: "Gérer les modules" },
|
|
||||||
{ id: "user_read", nom: "Consulter les utilisateurs" },
|
|
||||||
{ id: "user_write", nom: "Gérer les utilisateurs" },
|
|
||||||
{ id: "role_write", nom: "Gérer les rôles" },
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export const handler: Handlers<null, AuthenticatedState> = {
|
|
||||||
GET(_request, _context): Response {
|
|
||||||
return new Response(JSON.stringify(PERMISSIONS), {
|
|
||||||
headers: { "content-type": "application/json" },
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
import makeIndex from "$root/defaults/makeIndex.ts";
|
|
||||||
export default makeIndex(import.meta.dirname!);
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import {
|
|
||||||
getPartialsConfig,
|
|
||||||
makePartials,
|
|
||||||
} from "$root/defaults/makePartials.tsx";
|
|
||||||
import { FreshContext } from "$fresh/server.ts";
|
|
||||||
import { State } from "$root/routes/_middleware.ts";
|
|
||||||
|
|
||||||
export async function Index(request: Request, context: FreshContext<State>) {
|
|
||||||
return <h2>Welcome to Admin.</h2>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const config = getPartialsConfig();
|
|
||||||
export default makePartials(Index);
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { Handlers } from "$fresh/server.ts";
|
|
||||||
import { db } from "../../../../databases/db.ts";
|
|
||||||
import { ues } from "../../../../databases/schema.ts";
|
|
||||||
|
|
||||||
export const handler: Handlers = {
|
|
||||||
async GET() {
|
|
||||||
try {
|
|
||||||
const result = await db.select().from(ues);
|
|
||||||
|
|
||||||
return new Response(JSON.stringify(result), {
|
|
||||||
status: 200,
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error fetching UEs:", error);
|
|
||||||
return new Response("Failed to fetch data", { status: 500 });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user