Skip to content

Commit

Permalink
updated to remove comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Jan 31, 2024
1 parent 378aa9d commit 2a2a01f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from celery.utils.log import get_task_logger
from django.conf import settings
from django.db.models import Value, JSONField, Q
from django.utils import timezone
from django.utils.crypto import get_random_string
from django.utils.translation import gettext_lazy as _l
from django.utils.translation import ngettext
Expand All @@ -19,7 +20,7 @@
from oauth2_provider.models import clear_expired
from requests.exceptions import ConnectionError, HTTPError

from core.models import Announcement, User, Event, BlogPost
from core.models import Announcement, User, Event, BlogPost, Comment
from core.utils.tasks import get_random_username
from metropolis.celery import app

Expand Down Expand Up @@ -63,6 +64,8 @@ def delete_expired_users():
queryset = User.objects.filter(
is_active=False, last_login__lt=dt.datetime.now() - dt.timedelta(days=14)
)
comments = Comment.objects.filter(author__in=queryset)
comments.update(body=None, last_modified=timezone.now()) # if body is None "deleted on %last_modified% would be shown
queryset.update( # We need to object to not break posts or comments
first_name="Deleted",
last_name="User",
Expand Down

0 comments on commit 2a2a01f

Please sign in to comment.