from django.db import models
from django.db.models.options import override

#from .views import SearchableView
# ^^^ raises Circular Import

class Keyword(models.Model):
    """
    this is the model that should contain searchable keywords
    """
    text_de = models.CharField(max_length=40)
    text_en = models.CharField(max_length=40)

class Searchable(models.Model):
    """
    Abstract class for any model that should be searchable.
    This model will be searched for by the searchbox that is in every upper part of the website.

    This class is not a real abstract class, I need to query it in the main search, so thats impossible
    """
    title_de = models.CharField(max_length=50, default="Titel DE")
    title_en = models.CharField(max_length=50, default="title en")
    subtitle_de = models.CharField(max_length=50, blank=True)
    subtitle_en = models.CharField(max_length=50, blank=True)
    desc_de = models.CharField(max_length=250, unique=True, default="Beschreibung DE")
    desc_en = models.CharField(max_length=250, unique=True, default="Description EN")
    # may be empty/blank for some entries
    date = models.DateField(blank=True, null=True)
    keywords = models.ManyToManyField(Keyword)
    suburl = models.CharField(max_length=200, blank=True, null=True)

    @classmethod
    def regenerate_all_entries(cls):
        """
        regenerate all searchable items
        """
        raise NotImplementedError

class StaticSite(Searchable):
    """
    This model represents any static site, such as start:index, 
    that should show up in search.

    Every searchable view should inherit from start.views.SearchableView.
    # TODO automate scanning for SearchableView classes
    """
    

    @override
    def regenerate_all_entries(cls):

        # this does not actually contain all views, only those that should show
        # up in the search.
        # TODO automate searching for these
        #all_views: list[SearchableView] = []

        raise NotImplementedError
