mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-06-13 18:59:24 +00:00
Removes failsafe that was overzealous
This commit is contained in:
parent
c17a2ec55b
commit
27d99a0094
|
@ -8,7 +8,7 @@ from django.contrib.auth.models import AbstractUser
|
||||||
from django.contrib.postgres.fields import ArrayField, CICharField
|
from django.contrib.postgres.fields import ArrayField, CICharField
|
||||||
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.db import models, transaction, IntegrityError
|
from django.db import models, transaction
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from model_utils import FieldTracker
|
from model_utils import FieldTracker
|
||||||
|
@ -268,7 +268,10 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
"""a list of users who are permanently deleted"""
|
"""a list of users who are permanently deleted"""
|
||||||
return cls.objects.filter(
|
return cls.objects.filter(
|
||||||
is_active=False,
|
is_active=False,
|
||||||
deactivation_reason__in=["self_deletion", "moderator_deletion"],
|
deactivation_reason__in=[
|
||||||
|
"self_deletion",
|
||||||
|
"moderator_deletion",
|
||||||
|
],
|
||||||
).distinct()
|
).distinct()
|
||||||
|
|
||||||
def update_active_date(self):
|
def update_active_date(self):
|
||||||
|
@ -416,10 +419,6 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
|
|
||||||
def erase_user_data(self):
|
def erase_user_data(self):
|
||||||
"""Wipe a user's custom data"""
|
"""Wipe a user's custom data"""
|
||||||
if not self.is_permanently_deleted:
|
|
||||||
raise IntegrityError(
|
|
||||||
"Attempted to delete user data for improperly deleted user"
|
|
||||||
)
|
|
||||||
# mangle email address
|
# mangle email address
|
||||||
self.email = f"{uuid4()}@deleted.user"
|
self.email = f"{uuid4()}@deleted.user"
|
||||||
|
|
||||||
|
@ -432,12 +431,6 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
|
|
||||||
def erase_user_statuses(self, broadcast=True):
|
def erase_user_statuses(self, broadcast=True):
|
||||||
"""Wipe the data on all the user's statuses"""
|
"""Wipe the data on all the user's statuses"""
|
||||||
# safety valve: make sure the user is deleted
|
|
||||||
if not self.is_permanently_deleted:
|
|
||||||
raise IntegrityError(
|
|
||||||
"Attempted to delete statuses for improperly deleted user"
|
|
||||||
)
|
|
||||||
|
|
||||||
for status in self.status_set.all():
|
for status in self.status_set.all():
|
||||||
status.delete(broadcast=broadcast)
|
status.delete(broadcast=broadcast)
|
||||||
|
|
||||||
|
@ -447,6 +440,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
return not self.is_active and self.deactivation_reason in [
|
return not self.is_active and self.deactivation_reason in [
|
||||||
"self_deletion",
|
"self_deletion",
|
||||||
"moderator_deletion",
|
"moderator_deletion",
|
||||||
|
"activitypub_deletion",
|
||||||
]
|
]
|
||||||
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
|
|
|
@ -11,6 +11,7 @@ from bookwyrm import models, views
|
||||||
class InboxActivities(TestCase):
|
class InboxActivities(TestCase):
|
||||||
"""inbox tests"""
|
"""inbox tests"""
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
|
@ -97,7 +98,8 @@ class InboxActivities(TestCase):
|
||||||
self.assertEqual(models.Notification.objects.get(), notif)
|
self.assertEqual(models.Notification.objects.get(), notif)
|
||||||
|
|
||||||
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
||||||
def test_delete_user(self, _):
|
@patch("bookwyrm.activitystreams.remove_status_task.delay")
|
||||||
|
def test_delete_user(self, *_):
|
||||||
"""delete a user"""
|
"""delete a user"""
|
||||||
self.assertTrue(models.User.objects.get(username="rat@example.com").is_active)
|
self.assertTrue(models.User.objects.get(username="rat@example.com").is_active)
|
||||||
activity = {
|
activity = {
|
||||||
|
|
Loading…
Reference in a new issue