[feature] Added target_url_suffix param to notify signal #492#493
Conversation
📝 WalkthroughWalkthroughAdds an optional Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant notify.send
participant notify_handler
participant AbstractNotification.target_url
participant target object
notify.send->>notify_handler: pass target_url_suffix
notify_handler->>notify_handler: validate suffix
notify_handler->>AbstractNotification.target_url: store notification data
AbstractNotification.target_url->>target object: resolve base URL
target object-->>AbstractNotification.target_url: return base URL
AbstractNotification.target_url-->>notify.send: return suffixed URL
Suggested reviewers: Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (2 errors, 1 warning)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Incremental Review (since bc7d0ed)The changes between the previous review commit and HEAD resolve all prior findings:
The implementation is correct and focused; the Files Reviewed (5 files)
Previous Review Summary (commit bc7d0ed)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit bc7d0ed)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Reviewed by hy3:free · Input: 43.6K · Output: 2.2K · Cached: 121.2K |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openwisp_notifications/base/models.py`:
- Around line 241-243: Update the URL construction in the related-object URL
method around _get_related_object_url so the suffix is appended only when both
url and target_url_suffix are present and non-empty; otherwise return the
original url unchanged, preserving None or empty-string values without
formatting them into invalid URLs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3e1469c9-2c1f-4860-b865-6e04a1b7ebf6
📒 Files selected for processing (5)
docs/developer/notification-types.rstdocs/developer/sending-notifications.rstopenwisp_notifications/base/models.pyopenwisp_notifications/handlers.pyopenwisp_notifications/tests/test_notifications.py
📜 Review details
⏰ Context from checks skipped due to timeout. (17)
- GitHub Check: Python==3.13 | django~=5.1.0
- GitHub Check: Python==3.13 | django~=5.2.0
- GitHub Check: Python==3.12 | django~=5.2.0
- GitHub Check: Python==3.10 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.0.0
- GitHub Check: Python==3.12 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=5.2.0
- GitHub Check: Python==3.11 | django~=5.2.0
- GitHub Check: Python==3.10 | django~=5.0.0
- GitHub Check: Python==3.10 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=5.0.0
- GitHub Check: Python==3.11 | django~=5.1.0
- GitHub Check: Python==3.12 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=4.2.0
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (5)
**/models.py
📄 CodeRabbit inference engine (AGENTS.md)
Preserve swappable model support and integration with
openwisp-usersorganizations and memberships in Django models
Files:
openwisp_notifications/base/models.py
openwisp_notifications/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Mark user-facing strings as translatable with Django i18n helpers, typically
gettext_lazyimported as_
Files:
openwisp_notifications/base/models.pyopenwisp_notifications/handlers.pyopenwisp_notifications/tests/test_notifications.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Avoid unnecessary blank lines inside function and method bodies
Write comments and docstrings only when they explain why code is shaped a certain way. Put comments before the relevant code block instead of scattering them inside it
Files:
openwisp_notifications/base/models.pyopenwisp_notifications/handlers.pyopenwisp_notifications/tests/test_notifications.py
**/*.{py,html,txt,md}
📄 CodeRabbit inference engine (Custom checks)
For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework.
Files:
openwisp_notifications/base/models.pyopenwisp_notifications/handlers.pyopenwisp_notifications/tests/test_notifications.py
openwisp_notifications/{serializers,views,handlers,tasks}.py
📄 CodeRabbit inference engine (AGENTS.md)
Preserve validation and permission checks when changing serializers, views, handlers, or tasks that include notification payloads with related objects and URLs
Files:
openwisp_notifications/handlers.py
🧠 Learnings (1)
📚 Learning: 2026-05-07T16:17:11.806Z
Learnt from: pandafy
Repo: openwisp/openwisp-notifications PR: 450
File: openwisp_notifications/tests/test_selenium.py:276-285
Timestamp: 2026-05-07T16:17:11.806Z
Learning: In OpenWISP projects’ test code (e.g., openwisp-notifications), Celery is configured project-wide to run tasks eagerly/synchronously during tests (e.g., `CELERY_TASK_ALWAYS_EAGER=True` or an equivalent setting). Therefore, when reviewing these tests, don’t flag “race condition” or “async Celery” concerns for code that assumes task completion—tasks are guaranteed to finish before execution proceeds to the next line of test code.
Applied to files:
openwisp_notifications/tests/test_notifications.py
🔇 Additional comments (4)
openwisp_notifications/handlers.py (1)
158-165: LGTM!docs/developer/notification-types.rst (1)
60-77: LGTM!docs/developer/sending-notifications.rst (1)
67-125: LGTM!openwisp_notifications/tests/test_notifications.py (1)
167-208: LGTM!
|
@coderabbitai resolve |
✅ Action performedComments resolved and changes approved. |
Checklist
Reference to Existing Issue
Closes #492
Description of Changes
This PR adds a way to append a querystring or fragment to a notification target URL, especially for
generic_messagenotifications, without allowing callers to override the full URL. It does so by adding support for a new argumenttarget_url_suffixargument tonotify.send.