[fix] Added SocialAccount inline to UserAdmin when needed#507
[fix] Added SocialAccount inline to UserAdmin when needed#507nemesifier merged 3 commits intomasterfrom
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 0 minutes and 29 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe changes refactor the admin configuration for Django-allauth socialaccount models. The unregistration logic is reorganized to always unregister Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (4 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 |
Test Failures in CIHello @nemesifier, There are 3 test failures in the CI:
To address these failures, please review the test cases and the corresponding code logic for user modification and deletion, particularly in the |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@openwisp_users/admin.py`:
- Around line 682-683: Update the has_add_permission method signature to accept
an optional obj by changing def has_add_permission(self, request, obj): to
include a default (obj=None) so it matches Django's InlineModelAdmin signature
and aligns with the neighboring has_delete_permission(self, request, obj=None);
ensure only the signature is changed and behavior (returning False) remains the
same.
- Line 675: The import for SocialAccount is using the admin package instead of
the model; replace the incorrect import (from allauth.socialaccount.admin import
SocialAccount) with importing the model from allauth.socialaccount.models so the
SocialAccount symbol refers to the actual model class used in registrations and
admin classes (update the import statement where SocialAccount is referenced,
e.g., in the admin module that defines/administers social accounts).
- Around line 663-694: The unregister logic currently builds
_unregister_socialaccount_models and calls apps.get_model/unregister
unconditionally, causing LookupError when allauth.socialaccount is not
installed; wrap the list initialization and the for loop that calls
apps.get_model and admin.site.unregister inside a guard checking
allauth_settings.SOCIALACCOUNT_ENABLED (same condition that controls the
SocialAccountInline/UserAdmin.inlines), so the _unregister_socialaccount_models
list and the unregister loop only run when
allauth_settings.SOCIALACCOUNT_ENABLED is True.
🪄 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: 7f3da497-0cb4-444a-8ca8-5a7d7db8b78a
📒 Files selected for processing (2)
openwisp_users/admin.pytests/openwisp2/settings.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
- GitHub Check: Python==3.11 | django~=5.2.0
- GitHub Check: Python==3.12 | django~=5.2.0
- GitHub Check: Python==3.13 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=5.0.0
- GitHub Check: Python==3.10 | django~=5.1.0
- GitHub Check: Python==3.13 | django~=5.2.0
- GitHub Check: Python==3.10 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=5.2.0
- GitHub Check: Python==3.11 | django~=5.1.0
- GitHub Check: Python==3.12 | django~=5.0.0
- GitHub Check: Python==3.10 | django~=5.0.0
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (actions)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (Custom checks)
For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework (django.utils.translation.gettext, gettext_lazy, or ugettext aliases)
Files:
tests/openwisp2/settings.pyopenwisp_users/admin.py
If SOCIALACCOUNT_ADMIN_NEEDED is True, admins should be able to manage the social account records of users. [backport 1.2]
e5ef526 to
84b5186
Compare
Test Failures in
|
<h3>Django ImproperlyConfigured: allauth.socialaccount not installed</h3>Hello @nemesifier, The CI failed because the Fix: Ensure that If |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai resolve |
✅ Actions performedComments resolved and changes approved. |
If SOCIALACCOUNT_ADMIN_NEEDED is True, admins should be able to manage the social account records of users.
Reference to Existing Issue
Related to #501.
Checklist