from apps.core.admin.mixins import SingletonAdminMixin
from django.contrib import admin
from django.utils.safestring import mark_safe

from ..models import AuxiliaryConfig


@admin.register(AuxiliaryConfig)
class AuxiliaryConfigAdmin(SingletonAdminMixin, admin.ModelAdmin):
    list_display = ('allow_registration', 'error_switch', 'error_render')
    list_editable = ('error_switch', )
    list_display_links = ('allow_registration', )
    fieldsets = (
        ('注册设置', {
            'fields': ('allow_registration', )
        }),
        ('错误页面设置', {
            'fields': ('error_switch', 'error_render'),
            'description': '配置自定义错误页面相关参数'
        }),
        ('当代SEO设置', {
            'description':
            mark_safe(
                '<div class="alert alert-info">当代WEB规则中出现了很多规范和富媒体规则，OG、JSON-LD、Twitter Card便是比较显著的，如果你发现还有哪些规则需要添加，可以告诉我们。</div>'
            ),
            'fields':
            ('og_enabled', 'json_ld_enabled', "twitter_card_enabled"),
        }),
    )
