from django.contrib import admin
from .models import Progression
from courses.models import Course, Lesson

@admin.register(Progression)
class ProgressionAdmin(admin.ModelAdmin):
    list_display = ('user', 'course', 'get_percent', 'updated_at')
    list_filter = ('course', 'updated_at')
    search_fields = ('user__username', 'course__name')

    autocomplete_fields = ['course', 'completed_lessons']

    def get_percent(self, obj):
        return f"{obj.percent_completed}"
    get_percent.short_description = 'Progression'