from django.db import models
from django.contrib import admin
from web.models.base import BaseModel
from web.models.forum_subcategory import ForumSubcategory
from web.models.custom_user import CustomUser
from markdownx.models import MarkdownxField


class ForumPost(BaseModel):
    content = MarkdownxField()
    edited = models.BooleanField()
    sticky = models.BooleanField()
    created_by = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
    forum_subcategory = models.ForeignKey(ForumSubcategory, on_delete=models.CASCADE, related_name='posts')

    class Meta:
        db_table = 'forum_post'


class ForumPostAdmin(admin.ModelAdmin):
    search_fields = (
        'content',
        'edited',
        'created_by',
        'sticky',
        'forum_subcategory',
    )

    list_display = (
        'content',
        'edited',
        'created_by',
        'forum_subcategory',
        'sticky',
    )
