feat: 移除轮播图管理,系列活动改卡片布局,课程描述限10行,首页配置优化
All checks were successful
Deploy to Server / deploy (push) Successful in 2m4s
All checks were successful
Deploy to Server / deploy (push) Successful in 2m4s
This commit is contained in:
@@ -2,28 +2,20 @@ from django.contrib import admin
|
||||
from django.utils.html import format_html
|
||||
from unfold.admin import ModelAdmin
|
||||
from unfold.decorators import display
|
||||
from .models import Competition, CompetitionEnrollment, ScoreDimension, Project, ProjectFile, Score, Comment, HomePageConfig, CarouselItem
|
||||
|
||||
|
||||
class CarouselItemInline(admin.TabularInline):
|
||||
model = CarouselItem
|
||||
extra = 1
|
||||
tab = True
|
||||
fields = ('carousel_type', 'image', 'image_url', 'title', 'subtitle', 'status', 'status_color', 'date', 'location', 'order', 'is_active')
|
||||
autocomplete_fields = []
|
||||
from .models import Competition, CompetitionEnrollment, ScoreDimension, Project, ProjectFile, Score, Comment, HomePageConfig
|
||||
|
||||
|
||||
@admin.register(HomePageConfig)
|
||||
class HomePageConfigAdmin(ModelAdmin):
|
||||
list_display = ['id', 'main_title', 'carousel1_title', 'carousel2_title', 'organizer', 'undertaker', 'is_active']
|
||||
list_editable = ['main_title', 'carousel1_title', 'carousel2_title', 'organizer', 'undertaker', 'is_active']
|
||||
list_display = ['id', 'main_title', 'organizer', 'undertaker', 'is_active']
|
||||
list_editable = ['main_title', 'organizer', 'undertaker', 'is_active']
|
||||
fieldsets = (
|
||||
('首页Banner', {
|
||||
('封面图', {
|
||||
'fields': ('banner_image', 'banner_image_url'),
|
||||
'description': '首页顶部Banner图片,可以上传本地图片或填写URL'
|
||||
'description': '首页标题下方的封面图,可上传本地图片或填写URL'
|
||||
}),
|
||||
('标题设置', {
|
||||
'fields': ('main_title', 'carousel1_title', 'carousel2_title')
|
||||
'fields': ('main_title',)
|
||||
}),
|
||||
('主办单位', {
|
||||
'fields': ('organizer', 'undertaker')
|
||||
@@ -34,37 +26,6 @@ class HomePageConfigAdmin(ModelAdmin):
|
||||
)
|
||||
|
||||
|
||||
@admin.register(CarouselItem)
|
||||
class CarouselItemAdmin(ModelAdmin):
|
||||
list_display = ['title', 'carousel_type', 'status', 'location', 'order', 'is_active', 'created_at']
|
||||
list_filter = ['carousel_type', 'status', 'is_active']
|
||||
search_fields = ['title', 'subtitle', 'location']
|
||||
readonly_fields = ['image_preview']
|
||||
fieldsets = (
|
||||
('轮播图类型', {
|
||||
'fields': ('carousel_type',)
|
||||
}),
|
||||
('图片设置', {
|
||||
'fields': ('image', 'image_preview', 'image_url'),
|
||||
'description': '优先使用本地上传的图片,上传后可预览'
|
||||
}),
|
||||
('内容设置', {
|
||||
'fields': ('title', 'subtitle', 'status', 'status_color', 'date', 'location')
|
||||
}),
|
||||
('显示设置', {
|
||||
'fields': ('order', 'is_active')
|
||||
}),
|
||||
)
|
||||
|
||||
@display(description='图片预览')
|
||||
def image_preview(self, obj):
|
||||
if obj.image:
|
||||
return format_html('<img src="{}" style="max-width: 400px; max-height: 200px; border-radius: 8px;" />', obj.image.url)
|
||||
elif obj.image_url:
|
||||
return format_html('<img src="{}" style="max-width: 400px; max-height: 200px; border-radius: 8px;" />', obj.image_url)
|
||||
return "暂无图片"
|
||||
|
||||
|
||||
class ScoreDimensionInline(admin.TabularInline):
|
||||
model = ScoreDimension
|
||||
extra = 1
|
||||
|
||||
Reference in New Issue
Block a user