Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mateodurante
Copy link
Contributor

This pull request introduces several improvements to the handling of hierarchical relationships and event/network updates in the constituency models, as well as a minor cleanup in the views. The most significant changes focus on ensuring data integrity when updating or deleting network objects, preventing loops in parent relationships, and refactoring event and network reordering logic.

Hierarchy & Data Integrity Improvements

  • Added loop detection in the parent relationship validation to prevent cycles by tracking visited nodes in ngen/models/common/mixins.py. [1] [2]

Event & Network Reordering Logic

  • Refactored the save method in ngen/models/constituency.py to properly reorder events and networks when a network is updated, including handling changes in parent relationships and network attributes.
  • Added private helper methods (_reorder_events_of_my_parent_and_me, _reorder_networks_that_belongs_to_me) to encapsulate and clarify event/network reordering logic.
  • Updated the delete method in ngen/models/constituency.py to ensure that child networks and related events are correctly reassigned to the parent network upon deletion.

Code Cleanup

  • Removed unnecessary debug print statements from the get_by_contact_id view in ngen/views/constituency.py for cleaner API responses.

@mateodurante mateodurante merged commit 69f8f75 into develop Aug 25, 2025
6 checks passed
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.

2 participants