Skip to content

Commit 4d72621

Browse files
committed
Updated merge search interface to include historical changes to the transcription.
1 parent 72f6d46 commit 4d72621

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Generated by Django 4.2.23 on 2025-09-12 17:40
2+
3+
from django.db import migrations
4+
from django.db import models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("validation", "0055_alter_historicalphrase_origin_alter_phrase_origin"),
11+
]
12+
13+
operations = []
14+
15+
def add_history_relation(apps, schema_editor):
16+
HistoricalModel = apps.get_model("validation", "HistoricalPhrase")
17+
# "id" may differ depending on your base model's primary key field
18+
HistoricalModel.objects.update(history_relation=models.F("id"))
19+
20+
operations = [
21+
migrations.AddField(
22+
model_name="historicalphrase",
23+
name="history_relation",
24+
field=models.ForeignKey(
25+
blank=True,
26+
db_constraint=False,
27+
null=True,
28+
on_delete=models.deletion.DO_NOTHING,
29+
related_name="historical_records",
30+
to="validation.Phrase",
31+
),
32+
),
33+
migrations.RunPython(add_history_relation, migrations.RunPython.noop),
34+
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 4.2.23 on 2025-09-12 17:54
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("validation", "0056_auto_20250912_1140"),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name="historicalphrase",
16+
name="history_relation",
17+
field=models.ForeignKey(
18+
db_constraint=False,
19+
on_delete=django.db.models.deletion.DO_NOTHING,
20+
related_name="historical_records",
21+
to="validation.phrase",
22+
),
23+
),
24+
]

validation/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ class Phrase(models.Model):
371371
display_order = models.IntegerField(default=0)
372372

373373
# Keep track of Phrases' history, so we can review, revert, and inspect them.
374-
history = HistoricalRecords(excluded_fields=["semantic_classes"])
374+
history = HistoricalRecords(
375+
excluded_fields=["semantic_classes"], related_name="historical_records"
376+
)
375377

376378
class Meta:
377379
indexes = [

validation/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,9 +1303,11 @@ def merge_phrases_search(request, language):
13031303
Phrase.objects.filter(language=language)
13041304
.filter(
13051305
Q(transcription__contains=query)
1306+
| Q(historical_records__transcription__contains=query)
13061307
| Q(fuzzy_transcription__contains=to_indexable_form(query))
13071308
| Q(translation__contains=query)
13081309
)
1310+
.distinct()
13091311
.order_by("transcription")
13101312
)
13111313

0 commit comments

Comments
 (0)