from django.contrib import admin
from .models import (Room, RoomMembership, Message, BusinessProfile,
                     BusinessService, BusinessPost, BusinessFollower)

@admin.register(Room)
class RoomAdmin(admin.ModelAdmin):
    list_display = ["name", "slug", "room_type", "is_active", "is_private", "created_by"]
    list_filter = ["room_type", "is_active", "is_private"]
    search_fields = ["name", "slug"]

@admin.register(BusinessProfile)
class BusinessProfileAdmin(admin.ModelAdmin):
    list_display = ["shop_name", "owner", "category", "is_verified", "is_active", "followers_count"]
    list_filter = ["category", "is_verified", "near_campus"]
    search_fields = ["shop_name", "owner__username"]
    actions = ["verify_business", "unverify_business"]

    def verify_business(self, request, queryset):
        queryset.update(is_verified=True)
        self.message_user(request, f"{queryset.count()} businesses verified.")
    verify_business.short_description = "✅ Verify selected businesses"

    def unverify_business(self, request, queryset):
        queryset.update(is_verified=False)
    unverify_business.short_description = "❌ Remove verification"

admin.site.register(RoomMembership)
admin.site.register(BusinessService)
admin.site.register(BusinessPost)
admin.site.register(BusinessFollower)
