Search models - add clearer deprecation comments and warnings

Models should not be in use as of Wagtail 5.0, however the chooser for popular search terms was still referencing this.

Add another warning and add clearer Docstrings about the state of these models, to be removed in Wagtail 6.0
pull/10934/head
LB Johnston 2023-09-28 07:34:41 +10:00 zatwierdzone przez LB (Ben Johnston)
rodzic a2c9e9ab2c
commit 019015c698
1 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -22,6 +22,11 @@ from .utils import get_descendants_content_types_pks
class Query(models.Model):
"""
Deprecated - This model has been moved to `wagtail.contrib.search_promotions`.
This legacy model will be removed in Wagtail 6.0
"""
query_string = models.CharField(max_length=MAX_QUERY_STRING_LENGTH, unique=True)
wagtail_reference_index_ignore = True
@ -87,6 +92,11 @@ class Query(models.Model):
class QueryDailyHits(models.Model):
"""
Deprecated - This model has been moved to `wagtail.contrib.search_promotions`.
This legacy model will be removed in Wagtail 6.0
"""
query = models.ForeignKey(
Query, db_index=True, related_name="daily_hits", on_delete=models.CASCADE
)
@ -98,6 +108,14 @@ class QueryDailyHits(models.Model):
"""
Deletes all QueryDailyHits records that are older than a set number of days
"""
warnings.warn(
"The wagtailsearch.QueryDailyHits model has been moved to wagtail.contrib.search_promotions. "
"Please update your code to use the Query model from that app instead.",
RemovedInWagtail60Warning,
stacklevel=2,
)
days = (
getattr(settings, "WAGTAILSEARCH_HITS_MAX_AGE", 7) if days is None else days
)