Skip to content

Commit 0e1031f

Browse files
committed
feat: implement core modules for homework, timetable, payments, and staff routing with new frontend dashboard pages and initial database migrations
1 parent 5e10c08 commit 0e1031f

13 files changed

Lines changed: 1428 additions & 322 deletions

File tree

backend/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ app.use("/api/payments", paymentsRouter);
6161
app.use("/api/marks", require("./modules/marks/marks.routes"));
6262
app.use("/api/attendance", require("./modules/attendance/attendance.routes"));
6363
app.use("/api/homework", require("./modules/homework/homework.routes"));
64-
app.use("/api/timetable", require("./modules/academics/timetable.route"));
64+
app.use("/api/v1/timetable", require("./modules/timetable/timetable.routes"));
65+
app.use("/api/timetable", require("./modules/timetable/timetable.routes"));
6566
app.use("/api/teacher", require("./modules/academics/teacher.route"));
6667
app.use("/api/transport", require("./modules/transport/transport.routes"));
6768
app.use("/api/reports", require("./modules/reports/reports.route"));
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
-- 010_timetable_breaks.sql
2-
ALTER TABLE timetables
3-
ADD COLUMN is_break TINYINT(1) DEFAULT 0 AFTER end_time;
2+
ALTER TABLE timetables MODIFY COLUMN subject_id INT NULL;

backend/modules/homework/homework.routes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ router.put('/status', verifyToken, authorize(ROLES.STUDENT), async (req, res) =>
138138
// Teacher or Admin deletes homework
139139
router.delete('/:id', verifyToken, authorize(ROLES.TEACHER, ROLES.ADMIN, ROLES.SUPER_ADMIN), async (req, res) => {
140140
try {
141+
if (req.user.role === ROLES.TEACHER) {
142+
const [[hw]] = await pool.query('SELECT assigned_by FROM homework WHERE id = ?', [req.params.id]);
143+
if (!hw || Number(hw.assigned_by) !== Number(req.user.id)) {
144+
return res.status(403).json({ success: false, message: 'Not authorized to delete this homework assignment' });
145+
}
146+
}
141147
await svc.deleteHomework(req.params.id);
142148
res.json({ success: true, message: 'Homework deleted successfully' });
143149
} catch (err) {

backend/modules/payments/payments.route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ router.post('/create-order',
3333
);
3434

3535
// POST /api/payments/verify - Verify Razorpay payment signature
36-
router.post('/verify', verifyToken, async (req, res) => {
36+
router.post('/verify', verifyToken, authorize(...canCreateOrder), async (req, res) => {
3737
try {
3838
const result = await svc.verifyPayment(req.body);
3939
res.json({ success: true, data: result });

backend/modules/staff/teacherAssignment.routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ router.get('/my-assignments', verifyToken, authorize(ROLES.TEACHER), async (req,
3535
});
3636

3737
// Admin/Super Admin view of all teachers + assignments
38-
router.get('/all', verifyToken, authorize(...canManage, ROLES.SUPER_ADMIN), async (req, res) => {
38+
router.get('/all', verifyToken, authorize(...canManage), async (req, res) => {
3939
const rows = await svc.listAllTeachersWithAssignments();
4040
res.json({ success: true, data: rows });
4141
});

0 commit comments

Comments
 (0)