from django.contrib import admin

from .models import TLSPolicy, Domain, DomainOwner


class AdminInline(admin.TabularInline):
    model = DomainOwner
    extra = 1


class DomainAdmin(admin.ModelAdmin):
    list_display = [('domain'), ('admins')]
    inlines = [AdminInline]

    def admins(self, obj):
        return "[" + ", ".join([x.source + ":" + x.admin for x in obj.admin.all()]) + "]"


admin.site.register(Domain, DomainAdmin)


class TLSPolicyAdmin(admin.ModelAdmin):
    list_display = [('domain'), ('policy'), ('params')]


admin.site.register(TLSPolicy, TLSPolicyAdmin)
