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
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

1 participant