feat: 城市手册后端完成 - 用户/区域/内容/服务/审核系统
This commit is contained in:
57
city-manual/backend/content/admin.py
Normal file
57
city-manual/backend/content/admin.py
Normal file
@@ -0,0 +1,57 @@
|
||||
from django.contrib import admin
|
||||
from .models import Article, Comment, Like, Rating, Favorite
|
||||
|
||||
|
||||
@admin.register(Article)
|
||||
class ArticleAdmin(admin.ModelAdmin):
|
||||
list_display = ['title', 'region', 'content_type', 'author', 'moderator_status', 'ai_status', 'publish_status', 'created_at']
|
||||
list_filter = ['content_type', 'moderator_status', 'ai_status', 'publish_status']
|
||||
search_fields = ['title', 'content', 'author__username']
|
||||
ordering = ['-created_at']
|
||||
readonly_fields = ['moderator_reviewed_at', 'ai_reviewed_at']
|
||||
|
||||
|
||||
@admin.register(Comment)
|
||||
class CommentAdmin(admin.ModelAdmin):
|
||||
list_display = ['author', 'get_object', 'ai_status', 'is_visible', 'created_at']
|
||||
list_filter = ['ai_status', 'is_visible']
|
||||
search_fields = ['content', 'author__username']
|
||||
ordering = ['-created_at']
|
||||
|
||||
def get_object(self, obj):
|
||||
return obj.article or obj.service
|
||||
get_object.short_description = '对象'
|
||||
|
||||
|
||||
@admin.register(Like)
|
||||
class LikeAdmin(admin.ModelAdmin):
|
||||
list_display = ['user', 'get_object', 'created_at']
|
||||
search_fields = ['user__username']
|
||||
ordering = ['-created_at']
|
||||
|
||||
def get_object(self, obj):
|
||||
return obj.article or obj.service
|
||||
get_object.short_description = '对象'
|
||||
|
||||
|
||||
@admin.register(Rating)
|
||||
class RatingAdmin(admin.ModelAdmin):
|
||||
list_display = ['user', 'get_object', 'score', 'created_at']
|
||||
list_filter = ['score']
|
||||
search_fields = ['user__username', 'comment']
|
||||
ordering = ['-created_at']
|
||||
|
||||
def get_object(self, obj):
|
||||
return obj.region or obj.service
|
||||
get_object.short_description = '对象'
|
||||
|
||||
|
||||
@admin.register(Favorite)
|
||||
class FavoriteAdmin(admin.ModelAdmin):
|
||||
list_display = ['user', 'get_object', 'created_at']
|
||||
search_fields = ['user__username']
|
||||
ordering = ['-created_at']
|
||||
|
||||
def get_object(self, obj):
|
||||
return obj.region or obj.service
|
||||
get_object.short_description = '对象'
|
||||
Reference in New Issue
Block a user