from django.contrib import admin
from apps.course import models
# Register your models here.

@admin.register(models.Course)
class CourseAdmin(admin.ModelAdmin):
    '''课程'''

    list_display = ['name', 'desc', 'detail', 'degree', 'learn_times', 'students']
    search_fields = ['name', 'desc', 'detail', 'degree', 'students']
    list_filter = ['name', 'desc', 'detail', 'degree', 'learn_times', 'students']

@admin.register(models.Lesson)
class LessonAdmin(admin.ModelAdmin):
    '''章节'''

    list_display = ['course', 'name', 'add_time']
    search_fields = ['course', 'name']
    # 这里course__name是根据课程名称过滤
    list_filter = ['course__name', 'name', 'add_time']

@admin.register(models.Video)
class VideoAdmin(admin.ModelAdmin):
    '''视频'''

    list_display = ['lesson', 'name', 'add_time']
    search_fields = ['lesson', 'name']
    list_filter = ['lesson', 'name', 'add_time']

@admin.register(models.CourseResource)
class CourseResourceAdmin(admin.ModelAdmin):
    '''课程资源'''

    list_display = ['course', 'name', 'download', 'add_time']
    search_fields = ['course', 'name', 'download']
    list_filter = ['course__name', 'name', 'download', 'add_time']