Skip to content

Commit

Permalink
Show longer comment preview in admin
Browse files Browse the repository at this point in the history
Also add hyperlink bool in list view
  • Loading branch information
ffont committed Sep 15, 2023
1 parent 6ba54ca commit 80b0e2a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions comments/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
class CommentAdmin(admin.ModelAdmin):
fieldsets = ((None, {'fields': ('user', 'sound', 'comment')}),)
raw_id_fields = ('user', 'parent', 'sound')
list_display = ('user', 'created', 'get_comment_summary', 'sound')
list_display = ('user', 'created', 'get_comment_summary', 'contains_hyperlink', 'sound')
list_select_related = ('user', 'sound')
list_filter = ('contains_hyperlink',)
search_fields = ('comment', '=user__username', '=sound__id')
ordering = ('-created',)

@admin.display(description='Comment')
def get_comment_summary(self, obj):
max_len = 80
max_len = 160
return f"{obj.comment[:max_len]}{'...' if len(obj.comment) > max_len else ''}"

def has_add_permission(self, request):
Expand Down

0 comments on commit 80b0e2a

Please sign in to comment.