-
Notifications
You must be signed in to change notification settings - Fork 41
Pass previous parent id to moved.save so that children objects can compa... #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass previous parent id to moved.save so that children objects can compa... #17
Conversation
…mpare. Since the model is reloaded from database it is impossible to compare between original parent (i.e. cached) and new parent in children objects without explicitly passing in the previous parent id to the save method.
For example: Original parent cached here: https://github.com/edoburu/django-fluent-pages/blob/master/fluent_pages/models/db.py#L130 And used here: https://github.com/edoburu/django-fluent-pages/blob/master/fluent_pages/models/db.py#L295 But since the moved object is reloaded from the database after the move the cached parent is set equal to the now current parent. Passing in the previous parent allows this information to be preserved. |
I'm testing this now. I am getting a 500 error but it is hidden behind an ajax call. |
This is in case _original_parent becomes unreliable. This depends on a pull request in django-polymorphic-tree: django-polymorphic/django-polymorphic-tree#17
Okay that fixed the 500 I was getting. |
Very cool to have this sorted out! |
I was wondering the same thing. I don't know mptt well enough to have known whether or not that extra load was required. But I would prefer if the approach in this pull request was not needed and that we could remove that re-fetching, much cleaner, and doesn't add extra boilerplate like the save method. |
I just tried it with that re-fetch removed and it works fine. I can send another pull request with the change unless you want to do it? |
#18 with the re-fetch removed. |
Really nice! I've merged #18 now, and I guess this one can be closed :) |
I've released 0.9 now, with this fix included! |
...re.
Since the model is reloaded from database it is impossible to compare
between original parent (i.e. cached) and new parent in children objects
without explicitly passing in the previous parent id to the save method.