TR here means Treball de Recerca — the individual research project each student in Catalonia carries out for school. The work that was handed in and assessed is this repository up to and including commit
93b73e0(15 December 2025).Every commit after
93b73e0was made later and is outside the original project. That later work — a security remediation, a UI rebuild, an automated test suite and CI — was written months after the hand-in, with AI assistance, and formed no part of what was graded. Theai-assisted-ui-overhaulbranch is later work in its entirety: it was cut from93b73e0and is not merged intomain.From commit
43a3d11onward, work done outside school is brought ontomain. Until thenmainheld only the assessed project plus documentation about it.43a3d11and8f8950eare the first commits to carry later application code here — a security remediation written months after the hand-in, on a personal branch, with AI assistance. They arrived by cherry-pick, not by merging the branch, which is why8f8950erecords the commit it came from.To read the project exactly as it was submitted:
git checkout 93b73e0
My TR consists in a comprehensive school management web application built with Django. It provides a digital platform for managing the academic lifecycle, including student enrollment, course management, grading, and attendance tracking. The system is designed to serve multiple user roles: Administrators, Professors, Tutors (Parents), and Students.
- Backend Framework: Python / Django 5.2
- Database: PostgreSQL (running in Docker)
- Frontend: HTML5, CSS3, JavaScript (Vanilla + jQuery)
- Containerization: Docker / Podman
- Environment Management:
venv(Python Virtual Environment)
- Administrators: Full control over the system. Can create school years, define course structures, and manage users.
- Professors: Access to assigned classes. Can grade students, record absences, and download/upload class data.
- Tutors (Parents): View-only access to their children's academic records (grades, absences).
- Students: Personal dashboard to view their own grades and attendance history.
- School Years & Trimesters: Flexible system to define academic years (e.g., "2025-2026") and their associated trimesters.
- Course Structure: Support for different educational levels (ESO, Bachillerato, IB) and sections (e.g., "1A", "2B").
- Cascading Logic: Smart forms that filter levels and sections dynamically based on the selected course type.
- Gradebook: Record grades for exams, partials, and finals.
- Attendance Tracking: Log absences and delays with timestamps.
- Data Export/Import:
- Download class lists and grade templates as CSV.
- Bulk import grades via CSV upload.
TR/
├── mainapp/ # Core application logic
│ ├── models.py # Database schemas (Students, Courses, Grades, etc.)
│ ├── views.py # Business logic and request handling
│ ├── forms.py # Form definitions and validations
│ └── templates/ # HTML templates for the UI
├── tr_webpage/ # Project configuration (settings, urls)
├── static/ # Static assets (CSS, JS, Images)
├── templates/ # Global templates (base.html, navbar, sidebar)
├── compose.yaml # Docker Compose configuration for PostgreSQL
└── run.sh # Helper script to launch the environment
- Python 3.10+
- Podman (for running the database)
- Tmux (optional, for using the
run.shscript)
-
Clone the repository:
git clone <repository_url> cd TR
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
Use
requirements-dev.txtinstead if you wantpodman-composeand theFaker-based seed command as well. -
Create your
.env: The application no longer carries aSECRET_KEYor a database password in source. Both are read from the environment, and it will not start without them.cp .env.example .env
Then fill in
SECRET_KEYandPOSTGRES_PASSWORD..env.exampledocuments every variable and includes the command for generating a key.
You can run the application using the provided script or manually.
This script manages the database container and the Django server in a tmux session.
./run.sh- What it does:
- Starts the PostgreSQL database using
podman-compose. - Starts the Django development server.
- Attaches to a
tmuxsession where you can see both logs.
- Starts the PostgreSQL database using
- To detach: Press
Ctrl+bthend. - To stop: Kill the tmux session or press
Ctrl+cin the panes.
-
Start the Database: Ensure you have Podman installed.
podman-compose up -d
-
Run Migrations (First time only):
python manage.py migrate
-
Create Superuser (First time only):
python manage.py createsuperuser
-
Start the Server:
python manage.py runserver
Access the application at http://127.0.0.1:8000/.
- Access the Admin Panel:
- URL:
http://127.0.0.1:8000/admin - Use the superuser credentials to log in (default:
admin/admin- checkcompose.yamlfor DB creds, Django admin user may need creation).
- URL:
-
AJAX: The application uses jQuery for dynamic form interactions (e.g., selecting a course type loads the available levels).
-
Security:
SECRET_KEY,DEBUG,ALLOWED_HOSTSand the database credentials all come from the environment (see.env.example). A remediation round in8f8950eadded a Content Security Policy, login throttling and rate limiting, secure cookie and transport flags, an audit log, and fixes for a DOM XSS and a Django-admin privilege escalation.⚠️ The remediation is partial, and this branch is not hardened. Two findings rated critical are still open here: there is no object-level authorization (any authenticated user can reach another user's records by changing an id in the URL), and several endpoints check only that you are logged in, not who you are. Both were fixed onai-assisted-ui-overhaul, but only as part of the UI rewrite, so neither could be cherry-picked on its own.GradeFormis also still declared twice, the second shadowing the first, and denials still render with HTTP 200. Do not deploy this branch to a public network.