Skip to content
Open
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
19 changes: 16 additions & 3 deletions adhocracy4/comments_async/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import gettext as _
from easy_thumbnails.files import get_thumbnailer
from guest_user.functions import is_guest_user
from rest_framework import serializers

from adhocracy4.api.dates import get_datetime_display
Expand Down Expand Up @@ -79,16 +80,28 @@ def to_representation(self, instance):
return ret

def get_user_profile_url(self, obj):
if obj.is_censored or obj.is_removed or obj.is_blocked:
if (
is_guest_user(obj.creator)
or obj.is_censored
or obj.is_removed
or obj.is_blocked
):
return ""
try:
return obj.creator.get_absolute_url()
except AttributeError:
return ""

def get_user_name(self, obj):
"""Don't show username if comment is marked removed or censored."""
if obj.is_censored or obj.is_removed or obj.is_blocked:
"""
For arpas, guest users will only be created in the AR experience.
Therefore if a user is guest, display "AR comment" in place of username.

Don't show username if comment is marked removed or censored.
"""
if is_guest_user(obj.creator):
return _("AR comment")
elif obj.is_censored or obj.is_removed or obj.is_blocked:
return _("unknown user")
return obj.creator.get_short_name()

Expand Down
5 changes: 5 additions & 0 deletions changelog/ST-490.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Added
- dependency: django-guest-user

### Changed
- comments: guest users are labeled as "AR comment" for the username
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ django-autoslug==1.9.9
https://github.com/liqd/django-ckeditor-5/releases/download/v0.2.11-liqd/django_ckeditor_5-0.2.11-py3-none-any.whl
django-enumfield==3.1
django-filter==24.3
django-guest-user @ git+https://github.com/liqd/django-guest-user.git
django-widget-tweaks==1.5.0
djangorestframework==3.15.2
djangorestframework-gis==1.1.0
Expand Down
Loading