Skip to content

Plugg update#527

Draft
georgelgeback wants to merge 25 commits intomainfrom
plugg-update
Draft

Plugg update#527
georgelgeback wants to merge 25 commits intomainfrom
plugg-update

Conversation

@georgelgeback
Copy link
Copy Markdown
Contributor

@georgelgeback georgelgeback commented Apr 13, 2026

Essentially done once copilot changes are considered. About 1500 LOC are just tests, so this is actually only a 2500 LOC PR :). We'll probably need to create some directories in the prod and stage environments(?), course documents and associated images needed somewhere new to go.

  • Programs own some number of program years, and connect to some number of specialisations (teknisk fysik)

  • Program years are specific years in the obligatory segment of a specific program (årskurs 1)

  • Specialisations can be shared between programs (bildanalys)

  • Courses can be shared between different programs and specialisations (lineär algebra)

  • Course documents can be divided into a bunch of categories and such, but belong only to one course

  • We also now send error codes (like 404) instead of just error messages, as a response when something goes wrong.

…rred to as associated_img. Not perfect though
… calls to backend. (e.g. program now "owns" specialisations, not the other way around)
…ting after file write problem. Allow None type duplicate course codes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new “Plugg” domain in the API (programs, program years, specialisations, courses), plus course documents and associated images, with extensive integration tests and some shared file-handling/cleanup utilities.

Changes:

  • Add new Plugg CRUD routers/models/schemas/services (including relationship management and URL-title lookups).
  • Add course document upload + associated image upload endpoints, along with cleanup logic for related files on deletion.
  • Add broad pytest coverage for the new endpoints and some new test storage configuration.

Reviewed changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tests/test_plugg_resources.py Large integration test suite for Plugg resources and relationships.
tests/test_documents.py Adds rollback test when document file write fails.
tests/test_course_documents.py Adds integration tests for course-document CRUD and file-write rollback.
tests/test_associated_img.py Adds integration tests for associated image upload/stream/delete and unlinking behavior.
tests/conftest.py Adds test env vars + directories for new storage areas; expires session between requests.
tests/basic_fixtures.py Adds permissions and an example_image_file fixture.
tests/basic_factories.py Adds request factories/helpers for new Plugg/course-document/associated-img endpoints.
services/specialisation_service.py Validates course IDs and maintains specialisation↔course join table.
services/program_year_service.py Validates course IDs and maintains program-year↔course join table.
services/program_service.py Validates specialisation IDs and maintains program↔specialisation join table.
services/plugg_cleanup_service.py Adds post-commit cleanup helpers for course docs + orphaned associated images.
services/img_service.py Adds config guard for album image uploads.
services/document_service.py Extracts shared PDF/file validation logic for documents and course-documents.
services/associated_img_service.py Adds storage + DB linking for associated images.
seed.py Adds new permissions seeding entries.
routes/specialisation_router.py Adds CRUD + by-url-title/by-program endpoints for specialisations.
routes/program_year_router.py Adds CRUD + by-url-title/by-program endpoints for program years.
routes/program_router.py Adds CRUD + by-url-title for programs; blocks delete if program years exist.
routes/document_router.py Refactors upload validation and adjusts commit/file-write ordering + cleanup.
routes/course_router.py Adds CRUD + lookup endpoints for courses; hooks cleanup on delete.
routes/course_document_router.py Adds CRUD + file-serving/redirect endpoints for course documents.
routes/associated_img_router.py Adds upload/delete/stream + nginx internal-redirect endpoint for associated images.
routes/init.py Registers the new routers in the main router.
main.py Adds a custom HTTPException handler returning {status_code, detail}.
helpers/url_formatter.py Adds backend URL-title formatting to mirror frontend behavior.
helpers/types.py Adds new permission targets and type literals for course docs + association types.
helpers/constants.py Adds max-length constants for new Plugg and course-document fields.
db_models/specialisation_model.py Adds Specialisation model including associations and associated image link.
db_models/specialisation_course_model.py Adds specialisation↔course join model.
db_models/program_year_model.py Adds ProgramYear model with per-program unique URL-title constraints.
db_models/program_year_course_model.py Adds program-year↔course join model.
db_models/program_specialisation_model.py Adds program↔specialisation join model.
db_models/program_model.py Adds Program model including specialisations, program years, and associated image link.
db_models/course_model.py Adds Course model, relationships, and updated-at tracking.
db_models/course_document_model.py Adds CourseDocument model.
db_models/associated_img_model.py Adds AssociatedImg model with 1:1 relationships to plugg entities.
api_schemas/specialisation_schema.py Adds request/response schemas for specialisations.
api_schemas/program_year_schema.py Adds request/response schemas for program years.
api_schemas/program_schema.py Adds request/response schemas for programs.
api_schemas/document_schema.py Removes unused UploadFile import.
api_schemas/course_schema.py Adds request/response schemas for courses.
api_schemas/course_document_schema.py Adds request/response schemas + multipart form helper for course docs.
api_schemas/associated_img_schema.py Adds associated image schemas.
.devcontainer/Dockerfile Adds env vars + directories for new storage paths in devcontainer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/course_document_router.py
Comment thread routes/course_document_router.py
Comment thread services/associated_img_service.py
Comment thread services/img_service.py
Comment thread routes/course_document_router.py
Comment thread services/associated_img_service.py
Comment thread api_schemas/course_schema.py
Comment thread routes/course_router.py
Comment thread routes/document_router.py
Comment thread services/document_service.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants