You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update documentation for recent features and fixes
Updated various markdown documentation files to reflect recent changes, including:
- Authenticated inline PDF opening and downloads.
- Improved grades PDF generation with null grade handling and bimester alignment.
- Filtering of all PDF reports by the current year.
- Frontend architectural changes: UserContext for state management, role-based UI adaptation, and middleware for route protection.
- Backend `TypeError` fix in grades PDF generation.
- Updates to development workflow and testing instructions, including the adoption of Biome for frontend linting and formatting.
Affected files:
- `README.md`
- `api/README.md`
- `app/README.md`
- `TESTING.md`
- `.github/CONTRIBUTING.md`
Copy file name to clipboardExpand all lines: .github/CONTRIBUTING.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,12 +74,17 @@ We enforce a consistent code style using automated tools. Please run them before
74
74
#### Frontend (TypeScript / Next.js)
75
75
76
76
- **Dependencies**: Managed with `npm`in`app/package.json`.
77
-
- **Linting & Formatting**: We use **ESLint**with the `next/core-web-vitals` configuration. Run the linter to check for issues:
77
+
- **Linting & Formatting**: We use **Biome**for linting and formatting. Run the checker to identify issues:
78
78
```bash
79
79
cd app/
80
-
npm run lint
80
+
npm run check
81
81
```
82
-
_We recommend integrating ESLint and a formatter like Prettier into your code editor to automatically format your code on save._
82
+
To automatically fix issues, run:
83
+
```bash
84
+
cd app/
85
+
npm run check:write
86
+
```
87
+
_We recommend integrating Biome into your code editor to automatically format and lint your code on save._
83
88
84
89
### API and Frontend Synchronization
85
90
@@ -105,6 +110,7 @@ Creste tests for all that you create (if applicable). Furthermore, reste the pro
105
110
cd app/
106
111
npm run test
107
112
```
113
+
Note: `npm run test` now includes automatic formatting and linting fixes via `biome check --write`.
108
114
- **End-to-End Testing**: The entire test suite (backend and frontend) can be run in a clean, containerized environment using the controller script. This is the same command our CI uses.
109
115
```bash
110
116
./controller.sh test
@@ -121,11 +127,11 @@ Once your changes are ready, follow these steps to submit a Pull Request.
121
127
Before opening a PR, please ensure you have completed the following:
122
128
123
129
- [ ] All backend and frontend tests are passing (`./controller.sh test`).
124
-
- [ ] The code is correctly formatted and passes all linter checks (`npm run lint`).
130
+
- [ ] The code is correctly formatted and passes all linter checks (`cd app/ &&npm run check:write`).
125
131
- [ ] The application starts and runs without errors (`./controller.sh start`).
126
132
- [ ] You have written new tests for your changes.
127
133
- [ ] You have updated the [**README.md**](README.md) if you introduced changes to the interface, environment variables, or exposed ports.
128
-
- [ ] You have documented significant changes in the [**NEW.md**](NEW.md) file.
134
+
129
135
- [ ] You have ensured that any new install or build dependencies are properly added to `pyproject.toml` or `package.json` and not left as local artifacts.
Copy file name to clipboardExpand all lines: README.md
+30-7Lines changed: 30 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,8 @@ Nginx acts as the entry point for all requests, directing them to the interface
49
49
50
50
The interface consumes the Backend's REST API via `axios`. Check the URLs used by the Frontend in the [`config.ts`](./app/src/config.ts) file.
51
51
52
+
For authenticated PDF downloads, the frontend now uses a dedicated utility (`openPdfInline`) that makes an authenticated `api.get` request to fetch the PDF content as a blob and then opens it in a new browser tab. This ensures secure access to sensitive documents.
53
+
52
54
Therefore, the following Frontend excerpt, on the events page
53
55
54
56
```ts
@@ -109,6 +111,18 @@ and, if acquiring the data, stores it in the `data` variable, so that the data c
109
111
110
112
The APP uses NextJS, a web framework, used in the construction of the components, together with React, as well as in the build function and to serve the static files.
111
113
114
+
### User Context for State Management
115
+
116
+
To centralize user data and roles, and to reduce redundant API calls, the application now utilizes a `UserContext`. This context provides a global state for the authenticated user's information, making it easily accessible across various components without prop drilling.
117
+
118
+
### Middleware for Route Protection
119
+
120
+
Sensitive routes and pages are protected by a Next.js middleware (`middleware.ts`). This middleware checks the user's authentication status and roles, redirecting unauthorized users or granting access based on defined permissions.
121
+
122
+
### Dynamic Dashboard and UserInfoCard
123
+
124
+
The Dashboard and `UserInfoCard` components have been rebuilt to dynamically adapt their content and functionality based on the authenticated user's role (e.g., Student, Guardian, Professor, Staff). This ensures a personalized and role-appropriate user experience.
125
+
112
126
### Endpoint Settings
113
127
114
128
The API endpoint settings are defined in [`config.ts`](./app/src/config.ts).
@@ -188,7 +202,9 @@ Follow this pattern to avoid circular imports.
188
202
189
203
There are functions in some serializers, which serve specific purposes, the so-called actions.
190
204
191
-
When data related to some model is extracted, such as the grades of a certain student, it is recommended to use an action:
205
+
When data related to some model is extracted, such as the grades of a certain student, it is recommended to use an action. The PDF generation for grades, presence, academic reports, and financial reports now filters data by the current year.
206
+
207
+
Example of `download_grades_pdf` with improved logic:
192
208
193
209
```py
194
210
. . .
@@ -199,11 +215,16 @@ class StudentViewSet(viewsets.ModelViewSet):
for grade in all_grades.filter(subject__full_name=subject):
224
+
bimester_num =int(grade.bimester[0])
225
+
if1<= bimester_num <=4:
226
+
bimester_grades[bimester_num -1] = grade.value
227
+
data[subject] = bimester_grades
207
228
return pdfgen(
208
229
"grades.html",
209
230
{"student": student, "data": data},
@@ -311,7 +332,8 @@ POST /api/users/token/
311
332
312
333
### Frontend
313
334
314
-
- Login is done through the `/auth/login` route, created by the [`login.ts`](<./app/src/app/(account)/auth/login/route.ts>) file, which sends the credentials to the backend and stores the tokens in cookies:
335
+
- Login is done through the `/auth/login` route, created by the [`login.ts`](<./app/src/app/(account)/auth/login/route.ts>) file, which sends the credentials to the backend and stores the tokens in cookies.
336
+
- The `UserContext` manages the authenticated user's state, including roles and permissions, making this information globally available across the application.
315
337
- The middleware ([`middleware.ts`](./app/src/middleware.ts)) protects sensitive routes:
316
338
- As long as the cookies persist, the user will remain authenticated even (except for the expiration policy configured in the Backend and cache cleaning).
317
339
@@ -391,14 +413,15 @@ Security is applied in the Backend, controlling access to each API endpoint base
-`GET /api/students/{id}/download-grades/` - Download student grades PDF
157
-
-`GET /api/students/{id}/download-presence/` - Download student presence PDF
156
+
-`GET /api/students/{id}/download-grades/` - Download student grades PDF (data filtered by current year)
157
+
-`GET /api/students/{id}/download-presence/` - Download student presence PDF (data filtered by current year)
158
158
-`GET /api/students/{id}/academic-report/` - Get comprehensive academic report (JSON)
159
-
-`GET /api/students/{id}/download-academic-report/` - Download academic report PDF
159
+
-`GET /api/students/{id}/download-academic-report/` - Download academic report PDF (data filtered by current year)
160
160
-`GET /api/students/students-needing-attention/` - List students needing notifications
161
-
-`GET /api/students/efficiency-analysis/?year=2025` - Get global efficiency analysis (approval & dropout rates)
161
+
-`GET /api/students/efficiency-analysis/?year={year}` - Get global efficiency analysis (approval & dropout rates). The `year` parameter is optional and defaults to the current year.
Copy file name to clipboardExpand all lines: app/README.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,17 +11,36 @@ The frontend is built with Next.js and contains the following pages:
11
11
### Main
12
12
13
13
-`/`: The main page of the application.
14
-
-`/dashboard`: The user's dashboard.
14
+
-`/dashboard`: The user's dashboard, which dynamically adapts its content and available actions based on the authenticated user's role (Student, Guardian, Professor, Staff).
15
15
-`/agenda`: The agenda page.
16
16
-`/events`: The events page.
17
17
-`/inbox`: The user's inbox.
18
18
-`/lessons`: The lessons page.
19
+
-`/week-planning`: A professor-specific page for managing weekly lesson plans.
19
20
-`/about`: The about page.
20
21
21
22
### Authentication
22
23
23
24
-`/auth/login`: The login page.
24
25
26
+
## Key Features and Components
27
+
28
+
### User Context for Global State Management
29
+
30
+
The application leverages a `UserContext` to manage the authenticated user's data and roles globally. This approach centralizes user information, making it readily available throughout the application and reducing the need for repetitive API calls or prop drilling.
31
+
32
+
### Role-Based UI Adaptation
33
+
34
+
Several key UI components, such as the `AppSidebar`, `UserInfoCard`, and the main Dashboard, are designed to dynamically adjust their display and functionality based on the authenticated user's role. This ensures a tailored and relevant user experience for Students, Guardians, Professors, and Staff members.
35
+
36
+
### Authenticated PDF Handling
37
+
38
+
A dedicated utility (`openPdfInline`) has been implemented to securely handle PDF documents. This utility makes authenticated requests to the backend to fetch PDF content as a blob and then opens it inline in a new browser tab, providing a seamless and secure viewing experience for reports and other documents.
39
+
40
+
### Middleware for Route Protection
41
+
42
+
Next.js middleware (`middleware.ts`) is used to enforce route protection. It intercepts requests to sensitive routes, verifies the user's authentication status and role, and grants or denies access accordingly. This ensures that users can only access the parts of the application they are authorized to see.
0 commit comments