Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the WebsiteContentDetailSerializer to prevent the automatic renaming of _index files when a page title is changed, and includes a new test case for this behavior. Feedback suggests also excluding the index filename from automatic renaming, as it is also a reserved Hugo filename.
| if ( | ||
| instance.type == CONTENT_TYPE_PAGE | ||
| and title | ||
| and instance.filename != "_index" | ||
| ): |
There was a problem hiding this comment.
The filename index is also a special Hugo filename (used for leaf bundles) and is explicitly listed in CONTENT_FILENAMES_FORBIDDEN. Similar to _index, it should likely be protected from automatic renaming when the title is updated to avoid breaking the page bundle structure.
| if ( | |
| instance.type == CONTENT_TYPE_PAGE | |
| and title | |
| and instance.filename != "_index" | |
| ): | |
| if ( | |
| instance.type == CONTENT_TYPE_PAGE | |
| and title | |
| and instance.filename not in ("index", "_index") | |
| ): |
for more information, see https://pre-commit.ci
|
Two questions/comments:
|
These directives are from drf-lint. This linter is responsible for detecting N+1 queries. ORM001 and ORM002 are rules in the linter. Since this PR affects serializers.py, the line numbers for some of the existing exceptions added in drf-lint-baseline.json(which contains exceptions for the linter) change, which cause the linter to fail. That is why we add noqas for these. I have now removed the releated lines from drf-lint-baseline.json as well. Now ruff does not like noqa codes that it can not recognize, in this case ORM001 and ORM002. Thus, we need to tell rust that these are codes for external linting tools with the
done |
What are the relevant tickets?
https://github.com/mitodl/hq/issues/10832
Description (What does it do?)
See comment
How can this be tested?