Skip to content

Conversation

@panagiotisevaggelou
Copy link

@panagiotisevaggelou panagiotisevaggelou commented Oct 20, 2025

This pull request adds permission checks for viewing and editing notification preferences, both in the API and in the admin interface.

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #312

Description of Changes

  • Updated PreferencesPermission in api/permissions.py and test_func in views.py to apply proper access rules.
  • Added a new template tag can_change_notifications to control when the “Notification Preferences” button is shown.
  • Added tests for all cases (superuser, regular user, staff with/without permission, and organization management).
  • Added extra comments in the code to make the logic easier to understand.

Notes

See my comment on the issue for more details.
This is a Draft PR and I would like some feedback, so I know I am on the right path.

Screenshot

Screenshot 2025-10-19 204458 Screenshot 2025-10-19 204541 Screenshot 2025-10-19 204619 Screenshot 2025-10-19 204654 Screenshot 2025-10-19 204747 Screenshot 2025-10-19 204816 Screenshot 2025-10-19 204911 Screenshot 2025-10-19 204940

Staff users with the change_notification_settings permission can now view
and modify notification preferences according to their organization membership.
Superusers retain full access, and regular users can only modify their own settings.

Fixes openwisp#312
@panagiotisevaggelou panagiotisevaggelou changed the title [notifications] Respect Django permissions for notification preferences Draft: [notifications] Respect Django permissions for notification preferences Oct 20, 2025
@nemesifier
Copy link
Member

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

Warning

Rate limit exceeded

@nemesifier has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 41 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between dc78de5 and 5b31ec4.

📒 Files selected for processing (5)
  • openwisp_notifications/api/permissions.py
  • openwisp_notifications/templates/admin/base_site.html
  • openwisp_notifications/templatetags/notification_tags.py
  • openwisp_notifications/tests/test_api.py
  • openwisp_notifications/views.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@panagiotisevaggelou thanks for contributing! The CI build is failing, please follow up with the reviews from coderabbit.

Sorry for my late repsonse, we've been avalanched with pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[change] Notification preferences: respect Django permissions

2 participants