|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
1 | 3 | """Signal handling for core app."""
|
2 | 4 |
|
3 | 5 | from __future__ import absolute_import
|
|
24 | 26 | '/api/v2/sustainability',
|
25 | 27 | ]
|
26 | 28 |
|
27 |
| - |
28 | 29 | webhook_github = Signal(providing_args=['project', 'data', 'event'])
|
29 | 30 | webhook_gitlab = Signal(providing_args=['project', 'data', 'event'])
|
30 | 31 | webhook_bitbucket = Signal(providing_args=['project', 'data', 'event'])
|
@@ -83,14 +84,17 @@ def delete_projects_and_organizations(sender, instance, *args, **kwargs):
|
83 | 84 | # Add annotate before filter
|
84 | 85 | # https://github.com/rtfd/readthedocs.org/pull/4577
|
85 | 86 | # https://docs.djangoproject.com/en/2.1/topics/db/aggregation/#order-of-annotate-and-filter-clauses # noqa
|
86 |
| - projects = (Project.objects.annotate(num_users=Count('users')).filter(users=instance.id) |
87 |
| - .exclude(num_users__gt=1)) |
| 87 | + projects = ( |
| 88 | + Project.objects.annotate(num_users=Count('users')) |
| 89 | + .filter(users=instance.id).exclude(num_users__gt=1) |
| 90 | + ) |
88 | 91 |
|
89 | 92 | # Here we count the users list from the organization that the user belong
|
90 | 93 | # Then exclude the organizations where there are more than one user
|
91 |
| - oauth_organizations = (RemoteOrganization.objects.annotate(num_users=Count('users')) |
92 |
| - .filter(users=instance.id) |
93 |
| - .exclude(num_users__gt=1)) |
| 94 | + oauth_organizations = ( |
| 95 | + RemoteOrganization.objects.annotate(num_users=Count('users')) |
| 96 | + .filter(users=instance.id).exclude(num_users__gt=1) |
| 97 | + ) |
94 | 98 |
|
95 | 99 | projects.delete()
|
96 | 100 | oauth_organizations.delete()
|
|
0 commit comments