[geo] keep floorplan org in sync with location#1210
[geo] keep floorplan org in sync with location#1210xoaryaa wants to merge 3 commits intoopenwisp:masterfrom
Conversation
WalkthroughThis PR fixes a bug where changing a location's organization does not synchronize the organization assignment to related floorplan objects. The solution adds a Sequence DiagramsequenceDiagram
participant Admin as Admin/User
participant Location as Location Model
participant Floorplan as Floorplan Model
participant DB as Database
Admin->>Location: Change organization_id
Location->>Location: save()
Note over Location: Detect org_id changed?
alt Organization Changed
Location->>DB: Fetch related floorplans
DB-->>Location: Floorplans data
Location->>Floorplan: Update organization_id on all<br/>related floorplans
Floorplan->>DB: Save changes
else Organization Unchanged
Location->>DB: Save location normally
end
Admin->>Floorplan: Access/Validate floorplan
Floorplan->>Floorplan: clean()
Floorplan->>Location: Verify org via location
Location-->>Floorplan: organization_id
Floorplan->>Floorplan: Sync org context
Floorplan->>DB: Validated and synced
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (4)📚 Learning: 2026-01-12T22:27:48.342ZApplied to files:
📚 Learning: 2026-01-15T15:05:49.557ZApplied to files:
📚 Learning: 2026-01-15T15:07:17.354ZApplied to files:
📚 Learning: 2026-01-15T14:06:53.460ZApplied to files:
🧬 Code graph analysis (1)openwisp_controller/geo/tests/test_models.py (3)
⏰ 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). (9)
🔇 Additional comments (3)
✏️ Tip: You can disable this entire section by setting 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 |
Checklist
Reference to Existing Issue
Closes #385
Description of Changes
FloorPlan.organizationcould remain stale after changing the relatedLocation.organization.Screenshot
no UI changes