Publish books website#39
Conversation
- Add HTTP controllers to serve book images publicly - Create /library/book/image/<id> endpoint for cover images - Create /library/book/back_cover/<id> endpoint for back covers - Update blog_post model to auto-convert image URLs to public - Add method to fix existing blog post cover URLs - Resolve merge conflicts in blog_post.py - Reduce cognitive complexity by extracting helper methods - Images now accessible without authentication for public visitors
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- blog_post.py: Extract _ensure_cover_properties_json() to avoid dict-to-JSON conversion duplication in create() and write() - product_template.py: * Extract _sync_product_image_attachment() for attachment management * Consolidate two write() calls into one in action_publish_to_blog() - controllers/main.py: Extract _serve_book_image() to eliminate 95% code duplication between book_image() and book_back_cover() Changes maintain full functionality while improving code maintainability and reducing database transactions.
There was a problem hiding this comment.
Pull request overview
This PR extends the jag_library Odoo addon to support publishing books to the website/blog, including public cover image URLs, configurable default blog selection, and associated UI/menu updates. It also adds repository-level tooling (pre-commit, lint/format configs, CI workflows) aligned with OCA automation.
Changes:
- Add website/blog publishing flow for books (blog post generation via QWeb template, config setting for default blog, UI buttons).
- Add public HTTP controller for serving book cover/back-cover images (with tests) and blog-post URL normalization.
- Introduce/refresh repo automation: pre-commit, ruff/pylint/eslint/prettier configs, GitHub Actions workflows, and generated README/docs artifacts.
Reviewed changes
Copilot reviewed 40 out of 43 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Adds whool PEP517 build backend config at repo root. |
| prettier.config.cjs | Adds Prettier config (incl. XML plugin) for formatting. |
| jag_library/views/website_blog_post_title_style_views.xml | Adds template inheritance to style blog post title/subtitle. |
| jag_library/views/res_partner_views.xml | Adds partner form updates + books tab and search filters. |
| jag_library/views/res_config_settings_views.xml | Adds Settings UI to select default blog for book publishing. |
| jag_library/views/product_template_views.xml | Extends product template view with subtitle, website publish flag, and publish-to-blog button(s). |
| jag_library/views/jag_library_menu_views.xml | Replaces menu/action definitions for Library app. |
| jag_library/views/jag_library_menu.xml | Removes old menu XML (renamed/replaced by *_views.xml). |
| jag_library/views/blog_post_views.xml | Adds blog.post form extension to expose cover_properties. |
| jag_library/views/blog_post_book_template_views.xml | Adds QWeb template used to render book content into blog posts. |
| jag_library/tests/test_public_images.py | Adds HttpCase tests for public image controller behavior. |
| jag_library/tests/test_book.py | Updates existing tests (savepoint for SQL constraint test, formatting). |
| jag_library/tests/test_blog_post.py | Adds tests for blog post cover URL conversion + product/blog relationship. |
| jag_library/tests/init.py | Registers new test modules. |
| jag_library/static/description/index.html | Adds generated module description HTML. |
| jag_library/security/library_security.xml | Defines module category + assigns groups to it. |
| jag_library/readme/USAGE.md | Adds README fragment for usage. |
| jag_library/readme/DESCRIPTION.md | Adds README fragment for description. |
| jag_library/readme/CONTRIBUTORS.md | Adds README fragment for contributors. |
| jag_library/pyproject.toml | Adds whool PEP517 build backend config for addon directory. |
| jag_library/models/res_config_settings.py | Adds config parameter-backed blog_id setting. |
| jag_library/models/product_template.py | Adds subtitle, website publish fields, blog publishing actions, attachment sync helpers. |
| jag_library/models/product_book_genre.py | Moves product.book.genre model into its own file. |
| jag_library/models/blog_post.py | Extends blog.post to normalize cover image URLs and add product linkage. |
| jag_library/models/init.py | Registers new model modules. |
| jag_library/i18n/es.po | Updates Spanish translations and adds QWeb strings. |
| jag_library/controllers/main.py | Adds public HTTP endpoints for book cover/back-cover image serving. |
| jag_library/controllers/init.py | Registers controllers package. |
| jag_library/manifest.py | Updates dependencies/data files for website/blog integration and new views. |
| jag_library/init.py | Loads controllers + models. |
| jag_library/README.rst | Adds generated README.rst content. |
| eslint.config.cjs | Adds ESLint configuration for JS linting. |
| README.md | Removes root README.md. |
| .vscode/settings.json | Extends VS Code settings with python project config. |
| .ruff.toml | Adds Ruff lint/format configuration. |
| .pylintrc-mandatory | Adds mandatory pylint-odoo config. |
| .pylintrc | Adds optional + mandatory pylint-odoo config. |
| .pre-commit-config.yaml | Adds pre-commit hooks (OCA hooks, ruff, pylint-odoo, prettier, eslint, etc.). |
| .gitignore | Adds a comprehensive Python-centric .gitignore. |
| .github/workflows/test.yml | Adds CI workflow to run OCA tests. |
| .github/workflows/stale.yml | Adds stale bot workflow. |
| .github/workflows/pre-commit.yml | Adds CI workflow to run pre-commit. |
| .DS_Store | Adds macOS metadata file (should not be committed). |
Comments suppressed due to low confidence (2)
jag_library/views/product_template_views.xml:81
- The header is modified twice with two separate
<xpath expr="//header" position="inside">blocks, andbutton_check_isbnis added in both, which will render duplicate "Verify ISBN" buttons. Consolidate into a single xpath insertion and keep each button definition only once.
jag_library/views/product_template_views.xml:38 <group string="Website Published"></group>is an empty group, and theis_website_publishedfield is placed outside of it. This makes the layout confusing and likely not what was intended. Put the field inside the group (or remove the group entirely) so the label/section is meaningful.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Copyright 2025 Javier Antó Garcia <hola@javieranto.com> | ||
| # License AGPL-3.0 or later (https://ww | ||
|
|
There was a problem hiding this comment.
The license header URL is truncated (https://ww), which breaks the standard AGPL header and will likely be flagged by tooling/checks. Replace it with the full AGPL-3.0 URL used elsewhere in the module.
| @@ -0,0 +1,202 @@ | |||
| jsdoc = require("eslint-plugin-jsdoc"); | |||
There was a problem hiding this comment.
jsdoc = require(...) assigns to an undeclared variable, which leaks a global and is easy to miss in Node/CommonJS configs. Declare it explicitly (e.g., with const) to avoid accidental globals.
| jsdoc = require("eslint-plugin-jsdoc"); | |
| const jsdoc = require("eslint-plugin-jsdoc"); |
No description provided.