from django.contrib import admin
from .models import Post, Comment, Like, Love, CommentLike, CommentDislike, Bookmark, Poll, PollOption, PollVote

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ["id", "author", "content_preview", "tag", "boosted_until", "created_at"]
    list_filter = ["tag", "created_at"]
    search_fields = ["author__username", "content"]
    readonly_fields = ["created_at", "updated_at"]
    def content_preview(self, obj): return obj.content[:60] if obj.content else "—"
    content_preview.short_description = "Content"

@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
    list_display = ["id", "user", "post", "text_preview", "created_at"]
    search_fields = ["user__username", "text"]
    def text_preview(self, obj): return obj.text[:60]
    text_preview.short_description = "Text"

admin.site.register(Like)
admin.site.register(Love)
admin.site.register(Bookmark)
admin.site.register(Poll)
admin.site.register(PollOption)
admin.site.register(PollVote)
