Portfolios: a plugin theme that sets only portfolios is offered in the picker, then refused on save #412
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#412
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, reading the theme picker and the theme field's validator, and confirmed by runningCVFormagainst the snapshot with a portfolio-only theme registered.Related to #132.
Checked again on 2026-10-01 against
mainat0a5cad587: still present. The code is now atdocuments/models.py:213(theme = theme_field(themes.Kind.CV)) anddocuments/models.py:52-67(theme_field);documents/themes.pyanddocuments/forms.pyhave not moved.The
CVmodel holds both CVs and portfolios, but itsthemecolumn is validated as if every row were a CV. A theme from a plugin that has a template for portfolios and not for CVs is offered on a portfolio's form and then refused by the model validator when the form is saved. The plugin contract explicitly allows such a theme ("a theme sets what it has a template for, and nothing else"), so a portfolio can never use it.documents/models.py:173(theme = theme_field(themes.Kind.CV)),documents/models.py:47-62(theme_field, which attachesthemes.SetsThisKind(kind)),documents/themes.py:236-258(SetsThisKind.__call__refuses whennot theme.sets(self.kind)),documents/forms.py:120-130(CVForm.theme_kind, which offersthemes.Kind.PORTFOLIOthemes for a portfolio).templates={ThemeKind.PORTFOLIO: ...}. A person creating a portfolio sees "Gallery, from Acme" in the theme menu, chooses it and saves.ModelFormvalidation runs the field validator fixed tocv, and the form comes back with "The Gallery theme does not set this kind of document." — about a pair the menu itself offered. Reproduced on the snapshot:CVForm(data={"name": "Work", "kind": "portfolio", "theme": "gallery", ...})lists('gallery', 'Gallery, from Acme')among its choices andis_valid()isFalsewith that error ontheme.tests/test_document_themes.pyregisters only letter-only and CV-only themes.CV.clean()that, whenthemes.find(self.theme)returns a theme, raises aValidationErroronthemewith codewrong_kindunlesstheme.sets(self.theme_kind). An unknown theme name must keep falling back toplainas it does now. The validator change alters the field's deconstruction, so it needs a migration.Done when
tests/test_document_themes.pyregisters a portfolio-only theme, saves a portfolio in it throughdocuments:cv_create, and asserts the portfolio exists with that theme; a second test asserts that a CV (kindcv) set in that theme is refused byfull_clean()with codewrong_kind.