Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set is_active to false when suspending user #1968

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/user/views/contribution_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def _get_latest_actions(self, author_id: str = None):
actions = (
self.get_filtered_queryset()
.exclude(Q(is_removed=True) | Q(display=False))
.exclude(user__is_active=False)
.filter(
user__isnull=False,
content_type__model__in=self._get_allowed_models(),
Expand Down
6 changes: 6 additions & 0 deletions src/user/views/user_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
user_to_censor = User.objects.get(author_profile__id=author_id)
user_to_censor.set_probable_spammer()
user_to_censor.set_suspended()
user_to_censor.is_active = False
user_to_censor.save()

Check warning on line 167 in src/user/views/user_views.py

View check run for this annotation

Codecov / codecov/patch

src/user/views/user_views.py#L166-L167

Added lines #L166 - L167 were not covered by tests
handle_spam_user_task(user_to_censor.id, request.user)

return Response({"message": "User is Censored"}, status=200)
Expand Down Expand Up @@ -746,6 +748,7 @@
def reinstate(self, request):
author_id = request.data["author_id"]
user = Author.objects.get(id=author_id).user
user.is_active = True

Check warning on line 751 in src/user/views/user_views.py

View check run for this annotation

Codecov / codecov/patch

src/user/views/user_views.py#L751

Added line #L751 was not covered by tests
user.is_suspended = False
user.probable_spammer = False
user.save()
Expand Down Expand Up @@ -791,6 +794,9 @@
f"Suspending User - {user.id}: {user.first_name} {user.last_name} - {decision_id}"
)
user.set_suspended(is_manual=False)
user.is_active = False
user.save()

Check warning on line 798 in src/user/views/user_views.py

View check run for this annotation

Codecov / codecov/patch

src/user/views/user_views.py#L797-L798

Added lines #L797 - L798 were not covered by tests

serialized = UserSerializer(user)
return Response(serialized.data, status=200)
else:
Expand Down
Loading