2023-08-10 11:27:31 -04:00
|
|
|
from auditlog.registry import auditlog
|
|
|
|
from django.conf import settings
|
2024-05-25 23:38:11 -04:00
|
|
|
from loguru import logger
|
2023-08-10 11:27:31 -04:00
|
|
|
|
|
|
|
from .book.models import Edition, EditionInSchema, EditionSchema, Series, Work
|
|
|
|
from .collection.models import Collection as CatalogCollection
|
2023-06-19 12:57:45 -04:00
|
|
|
from .common.models import (
|
2023-12-22 23:59:48 -05:00
|
|
|
AvailableItemCategory,
|
2023-06-19 12:57:45 -04:00
|
|
|
ExternalResource,
|
2023-08-11 01:43:19 -04:00
|
|
|
IdType,
|
2023-06-19 12:57:45 -04:00
|
|
|
Item,
|
2023-08-10 11:27:31 -04:00
|
|
|
ItemCategory,
|
2023-08-11 01:43:19 -04:00
|
|
|
ItemInSchema,
|
2023-06-19 12:57:45 -04:00
|
|
|
ItemSchema,
|
2023-08-11 01:43:19 -04:00
|
|
|
ItemType,
|
|
|
|
SiteName,
|
2023-06-19 12:57:45 -04:00
|
|
|
item_categories,
|
2023-08-10 11:27:31 -04:00
|
|
|
item_content_types,
|
2023-06-19 12:57:45 -04:00
|
|
|
)
|
2023-08-10 11:27:31 -04:00
|
|
|
from .game.models import Game, GameInSchema, GameSchema
|
|
|
|
from .movie.models import Movie, MovieInSchema, MovieSchema
|
|
|
|
from .music.models import Album, AlbumInSchema, AlbumSchema
|
2023-06-06 13:21:27 -04:00
|
|
|
from .performance.models import (
|
|
|
|
Performance,
|
|
|
|
PerformanceProduction,
|
|
|
|
PerformanceProductionSchema,
|
2023-08-10 11:27:31 -04:00
|
|
|
PerformanceSchema,
|
2023-06-06 13:21:27 -04:00
|
|
|
)
|
2023-08-10 11:27:31 -04:00
|
|
|
from .podcast.models import Podcast, PodcastEpisode, PodcastInSchema, PodcastSchema
|
|
|
|
from .tv.models import (
|
|
|
|
TVEpisode,
|
|
|
|
TVEpisodeSchema,
|
|
|
|
TVSeason,
|
|
|
|
TVSeasonInSchema,
|
|
|
|
TVSeasonSchema,
|
|
|
|
TVShow,
|
|
|
|
TVShowInSchema,
|
|
|
|
TVShowSchema,
|
|
|
|
)
|
|
|
|
|
2025-01-18 15:53:06 -05:00
|
|
|
from .search.models import Indexer, ExternalSearchResultItem # isort:skip
|
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-31 17:16:47 -05:00
|
|
|
def init_catalog_search_models():
|
2023-01-01 23:50:57 -05:00
|
|
|
if settings.DISABLE_MODEL_SIGNAL:
|
2024-05-25 23:38:11 -04:00
|
|
|
logger.warning(
|
2023-01-07 00:35:30 -05:00
|
|
|
"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)
|
2023-06-18 23:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
def init_catalog_audit_log():
|
|
|
|
for cls in Item.__subclasses__():
|
|
|
|
auditlog.register(
|
2023-06-19 00:17:56 -04:00
|
|
|
cls,
|
2023-06-19 16:37:35 -04:00
|
|
|
exclude_fields=[
|
|
|
|
"id",
|
|
|
|
"item_ptr",
|
|
|
|
"polymorphic_ctype",
|
|
|
|
"metadata",
|
|
|
|
"created_time",
|
|
|
|
"edited_time",
|
|
|
|
# related fields are not supported in django-auditlog yet
|
|
|
|
"lookup_ids",
|
|
|
|
"external_resources",
|
|
|
|
"merged_from_items",
|
|
|
|
"focused_comments",
|
|
|
|
],
|
2023-06-18 23:13:30 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
auditlog.register(
|
|
|
|
ExternalResource, include_fields=["item", "id_type", "id_value", "url"]
|
|
|
|
)
|
|
|
|
|
2024-05-25 23:38:11 -04:00
|
|
|
# logger.debug(f"Catalog audit log initialized for {item_content_types().values()}")
|
2024-05-27 15:44:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
"CatalogCollection",
|
|
|
|
"AvailableItemCategory",
|
|
|
|
"ExternalResource",
|
2025-01-18 15:53:06 -05:00
|
|
|
"ExternalSearchResultItem",
|
2024-05-27 15:44:12 -04:00
|
|
|
"IdType",
|
|
|
|
"Item",
|
|
|
|
"ItemCategory",
|
|
|
|
"ItemInSchema",
|
|
|
|
"ItemSchema",
|
|
|
|
"ItemType",
|
|
|
|
"SiteName",
|
|
|
|
"item_categories",
|
|
|
|
"item_content_types",
|
2024-05-29 10:50:41 -04:00
|
|
|
"Edition",
|
|
|
|
"EditionInSchema",
|
|
|
|
"EditionSchema",
|
|
|
|
"Series",
|
|
|
|
"Work",
|
2024-05-27 15:44:12 -04:00
|
|
|
"Game",
|
|
|
|
"GameInSchema",
|
|
|
|
"GameSchema",
|
|
|
|
"Movie",
|
|
|
|
"MovieInSchema",
|
|
|
|
"MovieSchema",
|
|
|
|
"Album",
|
|
|
|
"AlbumInSchema",
|
|
|
|
"AlbumSchema",
|
|
|
|
"Performance",
|
|
|
|
"PerformanceProduction",
|
|
|
|
"PerformanceProductionSchema",
|
|
|
|
"PerformanceSchema",
|
|
|
|
"Podcast",
|
|
|
|
"PodcastEpisode",
|
|
|
|
"PodcastInSchema",
|
|
|
|
"PodcastSchema",
|
|
|
|
"TVEpisode",
|
|
|
|
"TVEpisodeSchema",
|
|
|
|
"TVSeason",
|
|
|
|
"TVSeasonInSchema",
|
|
|
|
"TVSeasonSchema",
|
|
|
|
"TVShow",
|
|
|
|
"TVShowInSchema",
|
|
|
|
"TVShowSchema",
|
|
|
|
"Indexer",
|
|
|
|
"init_catalog_search_models",
|
|
|
|
"init_catalog_audit_log",
|
|
|
|
]
|