Skip to content

Commit 7ef5d1d

Browse files
committed
Candidate solution for #477
1 parent c524a5a commit 7ef5d1d

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

validation/jinja2/validation/_segment_card.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@
157157
{{ wrong_buttons.button_col(recording, csrf_token, request, language) }}
158158
{% if roles.is_linguist
159159
and (recording.wrong_speaker or recording.wrong_word)
160-
and recording.issue_set.count() > 0 %}
161-
{% if recording.issue_set.count() == 1 %}
160+
and recording.issue_set.filter(status="open").count() > 0 %}
161+
{% if recording.issue_set.filter(status="open").count() == 1 %}
162162
<a class="button button--neutral"
163163
data-cy="view-issue-button"
164-
href="{{ url('validation:issue_detail', language.code, recording.issue_set.get().id)}}">See Issue...</a>
164+
href="{{ url('validation:issue_detail', language.code, recording.issue_set.filter(status="open").get().id)}}">See Issue...</a>
165165
{% else %}
166166
<div class="dropdown">
167167
<button class="button button--neutral dropdown-toggle" data-cy="view-issue-button" data-toggle="dropdown" aria-expanded="false">Issues...</button>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Generated by Django 4.2.24 on 2025-09-22 16:24
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("validation", "0057_alter_historicalphrase_history_relation"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="historicalphrase",
15+
name="osid",
16+
field=models.CharField(
17+
blank=True,
18+
help_text="Typically, this is the os##### for Tsuut'ina recordings",
19+
max_length=16,
20+
null=True,
21+
),
22+
),
23+
migrations.AlterField(
24+
model_name="phrase",
25+
name="osid",
26+
field=models.CharField(
27+
blank=True,
28+
help_text="Typically, this is the os##### for Tsuut'ina recordings",
29+
max_length=16,
30+
null=True,
31+
),
32+
),
33+
]

validation/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ class Phrase(models.Model):
332332
osid = models.CharField(
333333
help_text="Typically, this is the os##### for Tsuut'ina recordings",
334334
null=True,
335+
blank=True,
335336
max_length=16,
336337
)
337338

validation/views.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from django.contrib.auth.views import LoginView, LogoutView
4444
from django.core.files.uploadedfile import InMemoryUploadedFile
4545
from django.core.paginator import Paginator
46-
from django.db.models import Q, QuerySet, Count, Case, When, IntegerField, F
46+
from django.db.models import Q, QuerySet, Count, Case, When, IntegerField, F, Max
4747
from django.http import (
4848
HttpResponse,
4949
HttpResponseBadRequest,
@@ -1674,13 +1674,18 @@ def handle_save_issue_with_recording(form, issue, request, language):
16741674
new_phrase = Phrase(
16751675
field_transcription=new_word,
16761676
transcription=new_word,
1677-
translation="",
1678-
kind="Sentence" if " " in new_word else "Word",
1677+
translation="[]",
1678+
kind=Phrase.SENTENCE if " " in new_word else Phrase.WORD,
16791679
date=datetime.datetime.now(),
1680+
language=rec.phrase.language,
16801681
modifier=str(request.user),
1682+
display_order=Phrase.objects.aggregate(Max("display_order", default=0))[
1683+
"display_order__max"
1684+
]
1685+
+ 1, # Place last
16811686
)
16821687
new_phrase.save()
1683-
rec.phrase_id = new_phrase.id
1688+
rec.phrase = new_phrase
16841689

16851690
rec.wrong_word = False
16861691
rec.wrong_speaker = False
@@ -1710,7 +1715,7 @@ def handle_save_issue_with_phrase(form, issue, request, language):
17101715
if translation:
17111716
phrase.translation = translation
17121717

1713-
phrase.status = "linked"
1718+
phrase.status = Phrase.LINKED
17141719
phrase.modifier = str(request.user)
17151720
phrase.date = datetime.datetime.now()
17161721
phrase.save()

0 commit comments

Comments
 (0)