diff --git a/mayan/apps/document_comments/apps.py b/mayan/apps/document_comments/apps.py index c7f123bef6..371d7d9be4 100644 --- a/mayan/apps/document_comments/apps.py +++ b/mayan/apps/document_comments/apps.py @@ -76,10 +76,7 @@ class DocumentCommentsApp(MayanAppConfig): ) SourceColumn(attribute='submit_date', source=Comment) - SourceColumn( - func=lambda context: context['object'].user.get_full_name() if context['object'].user.get_full_name() else context['object'].user, - source=Comment - ) + SourceColumn(attribute='get_user_label', source=Comment) SourceColumn(attribute='comment', source=Comment) document_page_search.add_model_field( diff --git a/mayan/apps/document_comments/models.py b/mayan/apps/document_comments/models.py index d0fb630f4a..9c0cb0b5be 100644 --- a/mayan/apps/document_comments/models.py +++ b/mayan/apps/document_comments/models.py @@ -60,6 +60,13 @@ class Comment(models.Model): viewname='comments:comment_details', kwargs={'pk': self.pk} ) + def get_user_label(self): + if self.user.get_full_name(): + return self.user.get_full_name() + else: + return self.user.username + get_user_label.short_description = _('User') + def save(self, *args, **kwargs): _user = kwargs.pop('_user', None) or self.user created = not self.pk