from django.contrib import admin
from .models import AboutSection, Church,ServiceTime, Leader,ChurchComment, HomepageSection

@admin.register(AboutSection)
class AboutSectionAdmin(admin.ModelAdmin):
    list_display = ('custom_label',)

    def custom_label(self, obj):
        return "My About Section"
    
@admin.register(HomepageSection)
class HomepageSectionAdmin(admin.ModelAdmin):  
    list_display = ('custom_label',) 

    def custom_label(self, obj):
        return "My Hoempage Section"
    
# Inline for ServiceTime
class ServiceTimeInline(admin.TabularInline):
    model = ServiceTime
    extra = 1  # number of empty forms shown

# Inline for Leader
class LeaderInline(admin.TabularInline):
    model = Leader
    extra = 1
      
# Inline for Comment
class CommentInline(admin.TabularInline):
    model = ChurchComment
    extra = 1
      
@admin.register(Church)
class ChurchAdmin(admin.ModelAdmin):
    list_display = ('name', 'city', 'state', 'country', 'email', 'created_at')
    search_fields = ('name', 'city', 'state', 'country', 'email')
    list_filter = ('country', 'state', 'created_at')
    inlines = [ServiceTimeInline, LeaderInline, CommentInline]
    
    
