2023-02-15 15:45:57 -05:00
|
|
|
from .common.models import Item, ItemSchema
|
|
|
|
from .book.models import Edition, Work, Series, EditionSchema, EditionInSchema
|
|
|
|
from .movie.models import Movie, MovieSchema, MovieInSchema
|
|
|
|
from .tv.models import (
|
|
|
|
TVShow,
|
|
|
|
TVSeason,
|
|
|
|
TVEpisode,
|
|
|
|
TVShowSchema,
|
|
|
|
TVShowInSchema,
|
|
|
|
TVSeasonSchema,
|
|
|
|
TVSeasonInSchema,
|
|
|
|
)
|
|
|
|
from .music.models import Album, AlbumSchema, AlbumInSchema
|
|
|
|
from .game.models import Game, GameSchema, GameInSchema
|
2023-04-19 22:31:27 -04:00
|
|
|
from .podcast.models import Podcast, PodcastSchema, PodcastInSchema, PodcastEpisode
|
2023-06-05 02:04:52 -04:00
|
|
|
from .performance.models import Performance, PerformanceProduction
|
2022-12-12 16:46:37 +00:00
|
|
|
from .collection.models import Collection as CatalogCollection
|
2023-06-03 11:10:48 -04:00
|
|
|
from .search.models import Indexer
|
2022-12-27 14:52:03 -05:00
|
|
|
from django.contrib.contenttypes.models import ContentType
|
2022-12-31 17:16:47 -05:00
|
|
|
from django.conf import settings
|
2023-01-07 00:35:30 -05:00
|
|
|
import logging
|
2022-12-31 17:16:47 -05:00
|
|
|
|
2023-01-07 00:35:30 -05:00
|
|
|
_logger = logging.getLogger(__name__)
|
2022-12-31 17:16:47 -05:00
|
|
|
|
2022-12-07 19:09:05 -05:00
|
|
|
|
|
|
|
# class Exhibition(Item):
|
|
|
|
|
|
|
|
# class Meta:
|
|
|
|
# proxy = True
|
|
|
|
|
|
|
|
|
|
|
|
# class Fanfic(Item):
|
|
|
|
|
|
|
|
# class Meta:
|
|
|
|
# proxy = True
|
|
|
|
|
|
|
|
|
2022-12-28 10:24:07 -05:00
|
|
|
_CATEGORY_LIST = None
|
|
|
|
_CONTENT_TYPE_LIST = None
|
|
|
|
|
|
|
|
|
|
|
|
def all_content_types():
|
|
|
|
global _CONTENT_TYPE_LIST
|
|
|
|
if _CONTENT_TYPE_LIST is None:
|
|
|
|
_CONTENT_TYPE_LIST = {}
|
|
|
|
for cls in Item.__subclasses__():
|
2022-12-29 23:57:02 -05:00
|
|
|
_CONTENT_TYPE_LIST[cls] = ContentType.objects.get(
|
|
|
|
app_label="catalog", model=cls.__name__.lower()
|
|
|
|
).id
|
2022-12-28 10:24:07 -05:00
|
|
|
return _CONTENT_TYPE_LIST
|
|
|
|
|
|
|
|
|
|
|
|
def all_categories():
|
|
|
|
global _CATEGORY_LIST
|
|
|
|
if _CATEGORY_LIST is None:
|
|
|
|
_CATEGORY_LIST = {}
|
|
|
|
for cls in Item.__subclasses__():
|
2022-12-29 23:57:02 -05:00
|
|
|
c = getattr(cls, "category", None)
|
2022-12-28 10:24:07 -05:00
|
|
|
if c not in _CATEGORY_LIST:
|
|
|
|
_CATEGORY_LIST[c] = [cls]
|
|
|
|
else:
|
|
|
|
_CATEGORY_LIST[c].append(cls)
|
|
|
|
return _CATEGORY_LIST
|
2022-12-31 17:16:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
def init_catalog_search_models():
|
2023-01-01 23:50:57 -05:00
|
|
|
if settings.DISABLE_MODEL_SIGNAL:
|
2023-01-07 00:35:30 -05:00
|
|
|
_logger.warn(
|
|
|
|
"Catalog models are not being indexed with DISABLE_MODEL_SIGNAL configuration"
|
|
|
|
)
|
2023-01-01 23:50:57 -05:00
|
|
|
return
|
2023-06-05 02:04:52 -04:00
|
|
|
# skip indexing if the item type should never show up in search
|
2022-12-31 17:16:47 -05:00
|
|
|
Indexer.update_model_indexable(Edition)
|
2023-06-05 02:04:52 -04:00
|
|
|
# Indexer.update_model_indexable(Work)
|
2022-12-31 17:16:47 -05:00
|
|
|
Indexer.update_model_indexable(Movie)
|
|
|
|
Indexer.update_model_indexable(TVShow)
|
|
|
|
Indexer.update_model_indexable(TVSeason)
|
|
|
|
Indexer.update_model_indexable(Album)
|
|
|
|
Indexer.update_model_indexable(Game)
|
2023-01-08 22:10:48 -05:00
|
|
|
Indexer.update_model_indexable(Podcast)
|
|
|
|
Indexer.update_model_indexable(Performance)
|
2023-06-05 02:04:52 -04:00
|
|
|
# Indexer.update_model_indexable(PerformanceProduction)
|
2023-01-08 22:10:48 -05:00
|
|
|
# Indexer.update_model_indexable(CatalogCollection)
|