Fix event and network modifications on network edit #231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
parentrelationship validation to prevent cycles by tracking visited nodes inngen/models/common/mixins.py. [1] [2]Event & Network Reordering Logic
savemethod inngen/models/constituency.pyto properly reorder events and networks when a network is updated, including handling changes in parent relationships and network attributes._reorder_events_of_my_parent_and_me,_reorder_networks_that_belongs_to_me) to encapsulate and clarify event/network reordering logic.deletemethod inngen/models/constituency.pyto ensure that child networks and related events are correctly reassigned to the parent network upon deletion.Code Cleanup
get_by_contact_idview inngen/views/constituency.pyfor cleaner API responses.