From b88a376d69c52369094bc58e448e7f9526faa723 Mon Sep 17 00:00:00 2001 From: p9xvr8cjz <2775939221@qq.com> Date: Fri, 7 Nov 2025 18:55:22 +0800 Subject: [PATCH] Delete 'comments/admin.py' --- comments/admin.py | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 comments/admin.py diff --git a/comments/admin.py b/comments/admin.py deleted file mode 100644 index a814f3f..0000000 --- a/comments/admin.py +++ /dev/null @@ -1,47 +0,0 @@ -from django.contrib import admin -from django.urls import reverse -from django.utils.html import format_html -from django.utils.translation import gettext_lazy as _ - - -def disable_commentstatus(modeladmin, request, queryset): - queryset.update(is_enable=False) - - -def enable_commentstatus(modeladmin, request, queryset): - queryset.update(is_enable=True) - - -disable_commentstatus.short_description = _('Disable comments') -enable_commentstatus.short_description = _('Enable comments') - - -class CommentAdmin(admin.ModelAdmin): - list_per_page = 20 - list_display = ( - 'id', - 'body', - 'link_to_userinfo', - 'link_to_article', - 'is_enable', - 'creation_time') - list_display_links = ('id', 'body', 'is_enable') - list_filter = ('is_enable',) - exclude = ('creation_time', 'last_modify_time') - actions = [disable_commentstatus, enable_commentstatus] - - def link_to_userinfo(self, obj): - info = (obj.author._meta.app_label, obj.author._meta.model_name) - link = reverse('admin:%s_%s_change' % info, args=(obj.author.id,)) - return format_html( - u'%s' % - (link, obj.author.nickname if obj.author.nickname else obj.author.email)) - - def link_to_article(self, obj): - info = (obj.article._meta.app_label, obj.article._meta.model_name) - link = reverse('admin:%s_%s_change' % info, args=(obj.article.id,)) - return format_html( - u'%s' % (link, obj.article.title)) - - link_to_userinfo.short_description = _('User') - link_to_article.short_description = _('Article')