Skip to content

Commit 4f9e4bf

Browse files
committed
Support filtering published, searchable entries based on a given datetime.
1 parent f1e280c commit 4f9e4bf

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

blog/admin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@
1111

1212
@admin.register(Entry)
1313
class EntryAdmin(admin.ModelAdmin):
14-
list_display = ("headline", "pub_date", "is_active", "is_published", "author")
15-
list_filter = ("is_active",)
14+
list_display = (
15+
"headline",
16+
"pub_date",
17+
"is_active",
18+
"is_published",
19+
"is_searchable",
20+
"author",
21+
)
22+
list_filter = ("is_active", "is_searchable")
1623
exclude = ("summary_html", "body_html")
1724
prepopulated_fields = {"slug": ("headline",)}
1825
raw_id_fields = ["social_media_card"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.2 on 2025-07-24 07:21
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('blog', '0005_entry_social_media_card'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='entry',
15+
name='is_searchable',
16+
field=models.BooleanField(help_text='Tick to make this entry allow this entry to appear in the Django documentation search.', null=True),
17+
),
18+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.2 on 2025-07-24 07:22
2+
3+
from django.db import migrations
4+
5+
6+
def set_is_searchable(apps, schema_editor):
7+
Entry = apps.get_model("blog", "Entry")
8+
# If this is large, this should be split into batched updates
9+
Entry.objects.filter(is_searchable__isnull=True).update(is_searchable=False)
10+
11+
class Migration(migrations.Migration):
12+
13+
dependencies = [
14+
('blog', '0006_entry_is_searchable'),
15+
]
16+
17+
operations = [
18+
migrations.RunPython(set_is_searchable, reverse_code=migrations.RunPython.noop, elidable=True),
19+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.2 on 2025-07-24 07:22
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('blog', '0007_set_is_searchable'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='entry',
15+
name='is_searchable',
16+
field=models.BooleanField(default=False, help_text='Tick to make this entry allow this entry to appear in the Django documentation search.'),
17+
),
18+
]

docs/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ def _sync_blog_to_db(self):
223223
Sync the blog entries into search based on the release documents
224224
support end date.
225225
"""
226-
if self.lang == "en":
227-
for entry in Entry.objects.published():
226+
if self.lang == "en" and self.support_end:
227+
for entry in Entry.objects.published(self.support_end):
228228
Document.objects.create(
229229
release=self,
230230
path=entry.get_absolute_url(),

0 commit comments

Comments
 (0)