# admin.py
from django.contrib import admin
from .models import FriendLink, LinkGroup


@admin.register(LinkGroup)
class LinkGroupAdmin(admin.ModelAdmin):
    list_display = ('name', 'alias', 'sort_order', 'created_at')
    list_editable = ('sort_order', )
    search_fields = ('name', 'alias')
    ordering = ('sort_order', )


@admin.register(FriendLink)
class FriendLinkAdmin(admin.ModelAdmin):
    list_display = ('title', 'alias', 'url', 'group', 'is_active',
                    'sort_order')
    list_filter = ('group', 'is_active')
    search_fields = ('title', 'alias', 'url')
    list_editable = ('sort_order', 'is_active')
    fieldsets = (('基本信息', {
        'fields': ('title', 'alias', 'url', 'group', 'description')
    }), ('媒体信息', {
        'fields': ('logo', ),
        'classes': ('wide', )
    }), ('状态设置', {
        'fields': ('is_active', 'is_nofollow', 'sort_order')
    }))
