Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
safwanrahman committed Aug 28, 2018
1 parent bb4f6e8 commit 33e4157
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion readthedocs/core/signals.py
Expand Up @@ -81,7 +81,7 @@ def delete_projects_and_organizations(sender, instance, *args, **kwargs):
# Here we count the owner list from the projects that the user own
# Then exclude the projects where there are more than one owner
# Add annotate before filter
# https://bit.ly/2Nne6ZJ
# https://docs.djangoproject.com/en/2.1/topics/db/aggregation/#order-of-annotate-and-filter-clauses # noqa
projects = (Project.objects.annotate(num_users=Count('users')).filter(users=instance.id)
.exclude(num_users__gt=1))

Expand Down
12 changes: 6 additions & 6 deletions readthedocs/core/tests/test_signals.py
@@ -1,7 +1,7 @@
import pytest
import django_dynamic_fixture

from django.contrib.auth.models import User
from django_dynamic_fixture import G

from readthedocs.oauth.models import RemoteOrganization
from readthedocs.projects.models import Project
Expand All @@ -18,8 +18,8 @@ def test_project_organization_get_deleted_upon_user_delete(self, model_class):
deleted.
"""

obj = G(model_class)
user1 = G(User)
obj = django_dynamic_fixture.get(model_class)
user1 = django_dynamic_fixture.get(User)
obj.users.add(user1)

obj.refresh_from_db()
Expand All @@ -38,9 +38,9 @@ def test_multiple_users_project_organization_not_delete(self, model_class):
when any of the user delete his account.
"""

obj = G(model_class)
user1 = G(User)
user2 = G(User)
obj = django_dynamic_fixture.get(model_class)
user1 = django_dynamic_fixture.get(User)
user2 = django_dynamic_fixture.get(User)
obj.users.add(user1, user2)

obj.refresh_from_db()
Expand Down

0 comments on commit 33e4157

Please sign in to comment.