DataTalksClub / DataTalksClub/website
Sub-modules phase A: additive DB models and constraints
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Part of the shared-curriculum sub-modules umbrella (#396), phase A of 4. Full design: _docs/planning/shared-curriculum-submodules-design.md (sections "Refined design" and "Constraints and what the renderers must know").
Goal
Additive-only database schema for shared-curriculum sub-modules and per-cohort homework anchoring. No behavior change for any existing content — every module currently has zero sub-modules and must keep rendering exactly as today.
Scope
- New model
courses.models.shared_curriculum.SharedSubModule: required FK toSharedModule(related_name="sub_modules"),position(int),slug,title,summary(optional), source provenance fields mirroringSharedModule's own (source_content_idetc.). Nooverview_markdown, no independentpublished/retired_at— a sub-module is a grouping, not an independently-publishable unit. Unique constraints:(module, position),(module, slug),(module, source_content_id). SharedLessongains a nullablesub_moduleFK.clean()validatessub_module.module_id == module_idwhen set.CohortSharedModulegains a nullablesub_moduleFK (the homework anchor selector) and:UniqueConstraint(fields=("cohort", "shared_module"), condition=Q(sub_module__isnull=True))UniqueConstraint(fields=("cohort", "sub_module"), condition=Q(sub_module__isnull=False))UniqueConstraint(fields=("terminal_homework",), condition=Q(terminal_homework__isnull=False))clean():sub_module.module_id == shared_module_idwhensub_moduleis set.- Update the model's docstring: a placement is one cohort's homework anchor on one node (module or one of its sub-modules) of a shared module — not merely "optional."
- Migrations: purely additive (new table, new nullable columns, new constraints on existing tables — verify the three new
CohortSharedModuleconstraints don't reject any existing row; they shouldn't, since every existing row hassub_module IS NULL). - Django admin: register
SharedSubModulewith reasonable list/search config, consistent with howSharedModuleis already registered.
Non-goals
- No importer/parser changes (phase B).
- No rendering changes (phase C).
- No
zoomcamp-ops/module.yaml/cohort.yamlschema changes (phase D). - No real sub-module data — this phase ships with zero
SharedSubModulerows in every environment.
Dependencies
- Depends on: none.
- Blocks: #397 (phase B), which needs these models to exist.
Acceptance criteria
-
make django-check/make migrations-checkpass. -
make test(full suite) passes with zero behavior change to any existing rendered page (verify by diffing rendered HTML for a couple of real shared-curriculum pages before/after, e.g. an llm-zoomcamp module page). - New model tests:
SharedSubModuleuniqueness constraints,SharedLesson.clean()cross-module rejection,CohortSharedModule.clean()cross-module rejection, all three newCohortSharedModuleconstraints (module-level dup rejected, sub-module-level dup rejected, a homework anchored twice rejected). -
manage.py migrateapplies cleanly end to end on a fresh database and on the existing local dev database; migration reverses cleanly. - Django admin renders
SharedSubModulewithout error.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read _docs/planning/shared-curriculum-submodules-design.md, especially the “Refined design” and “Constraints and what the renderers must know” sections, then inspect the existing SharedModule, SharedLesson, CohortSharedModule, and Django admin definitions. Implement only the additive models, fields, validation, constraints, migrations, admin registration, and tests described. Done means the Django checks, migration checks, full suite, fresh and existing migrations, reversal, and admin rendering pass without rendering changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 54/100