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

Fix sparse indexes when deleting #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

guilhermearaujo
Copy link
Member

No description provided.

drf_kit/models.py Outdated Show resolved Hide resolved
test_app/tests/tests_model.py Show resolved Hide resolved
Comment on lines +46 to +55
@receiver(post_delete)
def reorder_group(sender, instance, **kwargs):
from drf_kit.models import OrderedModelMixin # pylint: disable=import-outside-toplevel

if not issubclass(sender, OrderedModelMixin):
return

if previous := instance.previous():
# trigger the reordering
previous.save()
Copy link
Contributor

Choose a reason for hiding this comment

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

You can register signals for all instances of this model instead of registering to all, and them filtering.

version = "1.9.0"
version = "1.10.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 1.10.1

@@ -458,3 +458,37 @@ def test_create_before_range(self):
self.assertOrder(placement_2, 2)
self.assertOrder(placement_3, 3)
self.assertOrder(placement_4, 0)

def test_delete_within_range(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use factories now.

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.

None yet

3 participants