Skip to content

Commit 15a36c0

Browse files
committed
fixup according to comments
1 parent c48f611 commit 15a36c0

File tree

4 files changed

+10
-27
lines changed

4 files changed

+10
-27
lines changed

readthedocs/core/signals.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
import logging
66

77
from corsheaders import signals
8-
from django.contrib.auth import get_user_model
8+
from django.conf import settings
99
from django.db.models.signals import pre_delete
1010
from django.dispatch import Signal
1111
from django.db.models import Q, Count
1212
from django.dispatch import receiver
1313
from future.backports.urllib.parse import urlparse
1414

15-
from readthedocs.oauth.tasks import bulk_delete_oauth_remote_organizations
1615
from readthedocs.projects.models import Project, Domain
17-
from readthedocs.projects.tasks import bulk_delete_projects
1816

1917
log = logging.getLogger(__name__)
20-
User = get_user_model()
2118

2219
WHITELIST_URLS = ['/api/v2/footer_html', '/api/v2/search', '/api/v2/docsearch']
2320

@@ -68,22 +65,18 @@ def decide_if_cors(sender, request, **kwargs): # pylint: disable=unused-argumen
6865
return False
6966

7067

71-
@receiver(pre_delete, sender=User)
72-
def delete_projects_and_organizations(instance, *args, **kwargs):
68+
@receiver(pre_delete, sender=settings.AUTH_USER_MODEL)
69+
def delete_projects_and_organizations(sender, instance, *args, **kwargs):
7370
# Here we count the owner list from the projects that the user own
7471
# Then exclude the projects where there are more than one owner
75-
projects_id = (instance.projects.all().annotate(num_users=Count('users'))
76-
.exclude(num_users__gt=1)
77-
.values_list('id', flat=True))
72+
projects = instance.projects.all().annotate(num_users=Count('users')).exclude(num_users__gt=1)
7873

7974
# Here we count the users list from the organization that the user belong
8075
# Then exclude the organizations where there are more than one user
81-
oauth_organizations_id = (instance.oauth_organizations.annotate(num_users=Count('users'))
82-
.exclude(num_users__gt=1)
83-
.values_list('id', flat=True))
76+
oauth_organizations = instance.oauth_organizations.annotate(num_users=Count('users')).exclude(num_users__gt=1)
8477

85-
bulk_delete_projects.delay(projects_id)
86-
bulk_delete_oauth_remote_organizations.delay(oauth_organizations_id)
78+
projects.delete()
79+
oauth_organizations.delete()
8780

8881

8982
signals.check_request_enabled.connect(decide_if_cors)

readthedocs/oauth/tasks.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""Tasks for OAuth services"""
22

33
from __future__ import absolute_import
4-
from celery import task
54
from django.contrib.auth.models import User
65
from djcelery import celery as celery_app
76

87
from readthedocs.core.utils.tasks import PublicTask
98
from readthedocs.core.utils.tasks import permission_check
109
from readthedocs.core.utils.tasks import user_id_matches
11-
from readthedocs.oauth.models import RemoteOrganization
1210
from .services import registry
1311

1412

@@ -23,9 +21,5 @@ def run_public(self, user_id):
2321
for service in service_cls.for_user(user):
2422
service.sync()
2523

26-
@task()
27-
def bulk_delete_oauth_remote_organizations(organizations_id):
28-
RemoteOrganization.objects.filter(id__in=organizations_id).delete()
29-
3024

3125
sync_remote_repositories = celery_app.tasks[SyncRemoteRepositories.name]

readthedocs/projects/tasks.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,3 @@ def clear_html_artifacts(version):
984984
if isinstance(version, int):
985985
version = Version.objects.get(pk=version)
986986
remove_dir(version.project.rtd_build_path(version=version.slug))
987-
988-
989-
@task()
990-
def bulk_delete_projects(projects_id):
991-
Project.objects.filter(id__in=projects_id).delete()

readthedocs/templates/profiles/private/delete_account.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
<form method="POST" action=".">
1313
{% csrf_token %}
1414
{{ form }}
15-
<br>
16-
<strong>Be careful! This can not be undone!</strong>
15+
<div>
16+
<strong>{% trans "Be careful! This can not be undone!" %}</strong>
17+
</div>
1718
<input type="submit" name="submit" value="{% trans "Delete Account" %}" id="submit"/>
1819
</form>
1920
{% endblock %}

0 commit comments

Comments
 (0)