Skip to content
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

Proposal to solve #118 #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

viniciuscb
Copy link

Undeletes only the related models that were deleted in the same time.
This assumes that the model and all related were deleted in a cascade
operation that lasted less than 60 seconds. (Maybe this should be in a
configuration in settings.py?)

Signed-off-by: Vinicius Cubas Brand [email protected]

Undeletes only the related models that were deleted in the same time.
This assumes that the model and all related were deleted in a cascade
operation that lasted less than 60 seconds. (Maybe this should be in a
configuration in settings.py?)

Signed-off-by: Vinicius Cubas Brand <[email protected]>
Copy link
Contributor

@AndreasBackx AndreasBackx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine, though some more thought needs to be given whether this breaking change should be made in this way. There are reasons only undeleting all of them and only those who were also deleted with it. I would add a parameter to the undelete method that indicates you want this behaviour, instead of making it the default and making it a breaking change.

)

with patch.object(timezone, 'now', return_value=datetime.datetime(2012, 12, 21)) as mock_now:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the mock_now as it's unused. See the travis build log, which tests for pyflakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also separate this patch into a test to test for the behaviour you changed. Reason being is that you'd have to keep this in mind for all of the tests. Best to test for this separately each time imo.

@Gagaro
Copy link
Member

Gagaro commented May 13, 2019

I don't like adding this as it is, there will be race conditons with this.

Imho we should: add a setting/parameter to block this behaviour (undeleting related objects) and document this issue.

@AndreasBackx
Copy link
Contributor

@Gagaro could you give some more insight in what race conditions might occur?

What would you propose as a parameter/setting then? I'm not sure what your plan is.

@Gagaro
Copy link
Member

Gagaro commented May 17, 2019

Let's say we have an object Foobar with two relations: Foo and Bar.

User A delete Foo.

Then, User B delete FooBar by mistake. It deleted Bar at the same times. He decides to undelete it and it undeletes Bar but also Foo, which should stay deleted. This behaviour is not predictable.

@AndreasBackx
Copy link
Contributor

AndreasBackx commented May 17, 2019

You're right, I didn't think about multiple users. Perhaps we could provide some kind of functionality or leave it for others to propose on how to make this library more extendible in different ways?

So for now perhaps out of scope.

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.

3 participants