from django.contrib import admin
from .models import SubscriptionPlan, Subscription, AddOnPackage, SubscriptionAddOn


@admin.register(SubscriptionPlan)
class SubscriptionPlanAdmin(admin.ModelAdmin):
    list_display = ('name', 'price', 'duration')
    list_filter = ('duration',)
    search_fields = ('name',)

@admin.register(Subscription)
class SubscriptionAdmin(admin.ModelAdmin):
    list_display = ('user', 'plan', 'start_date', 'end_date', 'last_billed')
    list_filter = ('plan', 'start_date', 'end_date')
    search_fields = ('user__name', 'plan__name')

@admin.register(AddOnPackage)
class AddOnPackageAdmin(admin.ModelAdmin):
    list_display = ('name', 'price', 'description')
    search_fields = ('name',)

@admin.register(SubscriptionAddOn)
class SubscriptionAddOnAdmin(admin.ModelAdmin):
    list_display = ('subscription', 'add_on', 'quantity', 'added_on', 'total_price')
    list_filter = ('add_on', 'subscription__user')
    search_fields = ('subscription__user__name', 'add_on__name')
