Skip to content

Conversation

@Eeshu-Yadav
Copy link
Contributor

@Eeshu-Yadav Eeshu-Yadav commented Dec 26, 2025

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.

Refactored ReceiveUrlAdmin to inherit from CopyableFieldsAdmin instead of ModelAdmin
Eliminated code duplication in add_view/change_view methods
Made receive_url work as a copyable field automatically
Updated ProjectAdmin to use single inheritance (no longer needs UUIDAdmin + ReceiveUrlAdmin)
Updated tests to reflect correct behavior (copyable fields excluded from add forms

Fixes #344

@Eeshu-Yadav Eeshu-Yadav force-pushed the issues/344-ReceiveUrlAdmin-inherit-CopyableFieldAdmin branch from e6c43e2 to edd8283 Compare December 26, 2025 13:45
@coveralls
Copy link

coveralls commented Dec 26, 2025

Coverage Status

coverage: 97.225% (-0.03%) from 97.253%
when pulling 559f85e on Eeshu-Yadav:issues/344-ReceiveUrlAdmin-inherit-CopyableFieldAdmin
into 761112c on openwisp:master.

…isp#344

- Refactored ReceiveUrlAdmin to inherit from CopyableFieldsAdmin instead of ModelAdmin
- Eliminated code duplication in add_view/change_view methods
- Made receive_url work as a copyable field automatically
- Updated ProjectAdmin to use single inheritance (no longer needs UUIDAdmin + ReceiveUrlAdmin)
- Updated tests to reflect correct behavior (copyable fields excluded from add forms)
- Reduced JavaScript and Python logic repetition

This addresses the enhancement request to reduce repetition between
ReceiveUrlAdmin and CopyableFieldAdmin by using proper inheritance.

Fixes openwisp#344
@Eeshu-Yadav Eeshu-Yadav force-pushed the issues/344-ReceiveUrlAdmin-inherit-CopyableFieldAdmin branch from edd8283 to 559f85e Compare December 26, 2025 13:51
@nemesifier
Copy link
Member

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 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 16, 2026

📝 Walkthrough

Walkthrough

ReceiveUrlAdmin is refactored to inherit from CopyableFieldsAdmin instead of ModelAdmin, enabling the receive_url field to be marked as copyable. The ProjectAdmin test class is updated to inherit only from ReceiveUrlAdmin and explicitly configures copyable_fields for both "uuid" and "receive_url", with a custom uuid method implementation. Test assertions are updated to reflect the modified field ordering where receive_url now appears as a copyable field at the end of the admin form.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main refactoring change: making ReceiveUrlAdmin inherit from CopyableFieldAdmin and references issue #344.
Description check ✅ Passed The description covers the main changes, references the linked issue, and explains the refactoring benefits; however, test and documentation update checkboxes remain unchecked despite code changes.
Linked Issues check ✅ Passed The code changes successfully address the linked issue #344 by refactoring ReceiveUrlAdmin to inherit from CopyableFieldsAdmin, eliminating duplication of JavaScript and Python logic.
Out of Scope Changes check ✅ Passed All changes are directly related to the refactoring objective: modifying inheritance hierarchy, updating copyable fields configuration, and adjusting tests accordingly; no out-of-scope additions detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 761112c and 559f85e.

📒 Files selected for processing (3)
  • openwisp_utils/admin.py
  • tests/test_project/admin.py
  • tests/test_project/tests/test_admin.py
🧰 Additional context used
🧬 Code graph analysis (2)
tests/test_project/tests/test_admin.py (1)
openwisp_utils/admin.py (1)
  • get_fields (92-102)
tests/test_project/admin.py (1)
openwisp_utils/admin.py (1)
  • ReceiveUrlAdmin (153-207)
🪛 Ruff (0.14.11)
tests/test_project/admin.py

83-83: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

🔇 Additional comments (4)
openwisp_utils/admin.py (1)

153-169: LGTM: ReceiveUrlAdmin now reuses CopyableFieldsAdmin

This cleanly centralizes copyable-field behavior and keeps the receive_url exposure explicit.

tests/test_project/admin.py (1)

82-94: LGTM: ProjectAdmin single inheritance + explicit copyable_fields

The explicit uuid method and copyable_fields tuple make the new inheritance path clear and consistent.

tests/test_project/tests/test_admin.py (2)

213-219: LGTM: add-form exclusion for receive_url

This matches the expected CopyableFieldsAdmin behavior for add views.


254-259: LGTM: field-order assertion update

The assertion now reflects the new copyable-field ordering correctly.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

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] Refactor ReceiveUrlAdmin to inherit CopyableFieldAdmin

3 participants