Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy strings fixed #2668

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.db import transaction
from django.utils import timezone
from django.utils.timezone import localtime, make_aware, now
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from rest_framework.exceptions import ValidationError

Expand Down Expand Up @@ -157,14 +158,14 @@ class PatientConsultationSerializer(serializers.ModelSerializer):
many=True,
write_only=True,
required=False,
help_text="Bulk create diagnoses for the consultation upon creation",
help_text=_("Bulk create diagnoses for the consultation upon creation"),
)
diagnoses = ConsultationDiagnosisSerializer(many=True, read_only=True)
create_symptoms = EncounterCreateSymptomSerializer(
many=True,
write_only=True,
required=False,
help_text="Bulk create symptoms for the consultation upon creation",
help_text=_("Bulk create symptoms for the consultation upon creation"),
)
symptoms = EncounterSymptomSerializer(many=True, read_only=True)
medico_legal_case = serializers.BooleanField(default=False, required=False)
Expand Down
17 changes: 9 additions & 8 deletions care/facility/migrations_old/0058_auto_20200401_1820.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
# Generated by Django 2.2.11 on 2020-04-01 18:20

import fernet_fields.fields
Expand Down Expand Up @@ -27,14 +28,14 @@ class Migration(migrations.Migration):
model_name="historicalpatientregistration",
name="contact_with_confirmed_carrier",
field=models.BooleanField(
default=False, verbose_name="Confirmed Contact with a Covid19 Carrier"
default=False, verbose_name=_("Confirmed Contact with a Covid19 Carrier")
),
),
migrations.AddField(
model_name="historicalpatientregistration",
name="contact_with_suspected_carrier",
field=models.BooleanField(
default=False, verbose_name="Suspected Contact with a Covid19 Carrier"
default=False, verbose_name=_("Suspected Contact with a Covid19 Carrier")
),
),
migrations.AddField(
Expand All @@ -51,15 +52,15 @@ class Migration(migrations.Migration):
model_name="historicalpatientregistration",
name="has_SARI",
field=models.BooleanField(
default=False, verbose_name="Does the Patient Suffer from SARI"
default=False, verbose_name=_("Does the Patient Suffer from SARI")
),
),
migrations.AddField(
model_name="historicalpatientregistration",
name="past_travel",
field=models.BooleanField(
default=False,
verbose_name="Travelled to Any Foreign Countries in the last 28 Days",
verbose_name=_("Travelled to Any Foreign Countries in the last 28 Days"),
),
),
migrations.AddField(
Expand All @@ -76,14 +77,14 @@ class Migration(migrations.Migration):
model_name="patientregistration",
name="contact_with_confirmed_carrier",
field=models.BooleanField(
default=False, verbose_name="Confirmed Contact with a Covid19 Carrier"
default=False, verbose_name=_("Confirmed Contact with a Covid19 Carrier")
),
),
migrations.AddField(
model_name="patientregistration",
name="contact_with_suspected_carrier",
field=models.BooleanField(
default=False, verbose_name="Suspected Contact with a Covid19 Carrier"
default=False, verbose_name=_("Suspected Contact with a Covid19 Carrier")
),
),
migrations.AddField(
Expand All @@ -100,15 +101,15 @@ class Migration(migrations.Migration):
model_name="patientregistration",
name="has_SARI",
field=models.BooleanField(
default=False, verbose_name="Does the Patient Suffer from SARI"
default=False, verbose_name=_("Does the Patient Suffer from SARI")
),
),
migrations.AddField(
model_name="patientregistration",
name="past_travel",
field=models.BooleanField(
default=False,
verbose_name="Travelled to Any Foreign Countries in the last 28 Days",
verbose_name=_("Travelled to Any Foreign Countries in the last 28 Days"),
),
),
migrations.AddField(
Expand Down
9 changes: 5 additions & 4 deletions care/facility/migrations_old/0066_auto_20200402_1806.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
# Generated by Django 2.2.11 on 2020-04-02 18:06

from django.db import migrations, models
Expand All @@ -14,31 +15,31 @@ class Migration(migrations.Migration):
name="number_of_aged_dependents",
field=models.IntegerField(
default=0,
verbose_name="Number of people aged above 60 living with the patient",
verbose_name=_("Number of people aged above 60 living with the patient"),
),
),
migrations.AddField(
model_name="historicalpatientregistration",
name="number_of_chronic_diseased_dependents",
field=models.IntegerField(
default=0,
verbose_name="Number of people who have chronic diseases living with the patient",
verbose_name=_("Number of people who have chronic diseases living with the patient"),
),
),
migrations.AddField(
model_name="patientregistration",
name="number_of_aged_dependents",
field=models.IntegerField(
default=0,
verbose_name="Number of people aged above 60 living with the patient",
verbose_name=_("Number of people aged above 60 living with the patient"),
),
),
migrations.AddField(
model_name="patientregistration",
name="number_of_chronic_diseased_dependents",
field=models.IntegerField(
default=0,
verbose_name="Number of people who have chronic diseases living with the patient",
verbose_name=_("Number of people who have chronic diseases living with the patient"),
),
),
]
29 changes: 15 additions & 14 deletions care/facility/migrations_old/0067_auto_20200402_1841.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
# Generated by Django 2.2.11 on 2020-04-02 18:41

from django.db import migrations, models
Expand Down Expand Up @@ -26,7 +27,7 @@ class Migration(migrations.Migration):
],
max_length=4,
null=True,
verbose_name="Blood Group of Patient",
verbose_name=_("Blood Group of Patient"),
),
),
migrations.AlterField(
Expand All @@ -35,7 +36,7 @@ class Migration(migrations.Migration):
field=models.TextField(
blank=True,
default="",
verbose_name="Countries Patient has Travelled to",
verbose_name=_("Countries Patient has Travelled to"),
),
),
migrations.AlterField(
Expand All @@ -44,7 +45,7 @@ class Migration(migrations.Migration):
field=models.DateTimeField(
blank=True,
null=True,
verbose_name="Return Date from the Last Country if Travelled",
verbose_name=_("Return Date from the Last Country if Travelled"),
),
),
migrations.AlterField(
Expand All @@ -61,7 +62,7 @@ class Migration(migrations.Migration):
(5, "EXPIRED"),
],
default=1,
verbose_name="Disease Status",
verbose_name=_("Disease Status"),
),
),
migrations.AlterField(
Expand All @@ -70,7 +71,7 @@ class Migration(migrations.Migration):
field=models.IntegerField(
blank=True,
default=0,
verbose_name="Number of people aged above 60 living with the patient",
verbose_name=_("Number of people aged above 60 living with the patient"),
),
),
migrations.AlterField(
Expand All @@ -79,14 +80,14 @@ class Migration(migrations.Migration):
field=models.IntegerField(
blank=True,
default=0,
verbose_name="Number of people who have chronic diseases living with the patient",
verbose_name=_("Number of people who have chronic diseases living with the patient"),
),
),
migrations.AlterField(
model_name="historicalpatientregistration",
name="present_health",
field=models.TextField(
blank=True, default="", verbose_name="Patient's Current Health Details"
blank=True, default="", verbose_name=_("Patient's Current Health Details")
),
),
migrations.AlterField(
Expand All @@ -106,7 +107,7 @@ class Migration(migrations.Migration):
],
max_length=4,
null=True,
verbose_name="Blood Group of Patient",
verbose_name=_("Blood Group of Patient"),
),
),
migrations.AlterField(
Expand All @@ -115,7 +116,7 @@ class Migration(migrations.Migration):
field=models.TextField(
blank=True,
default="",
verbose_name="Countries Patient has Travelled to",
verbose_name=_("Countries Patient has Travelled to"),
),
),
migrations.AlterField(
Expand All @@ -124,7 +125,7 @@ class Migration(migrations.Migration):
field=models.DateTimeField(
blank=True,
null=True,
verbose_name="Return Date from the Last Country if Travelled",
verbose_name=_("Return Date from the Last Country if Travelled"),
),
),
migrations.AlterField(
Expand All @@ -141,7 +142,7 @@ class Migration(migrations.Migration):
(5, "EXPIRED"),
],
default=1,
verbose_name="Disease Status",
verbose_name=_("Disease Status"),
),
),
migrations.AlterField(
Expand All @@ -150,7 +151,7 @@ class Migration(migrations.Migration):
field=models.IntegerField(
blank=True,
default=0,
verbose_name="Number of people aged above 60 living with the patient",
verbose_name=_("Number of people aged above 60 living with the patient"),
),
),
migrations.AlterField(
Expand All @@ -159,14 +160,14 @@ class Migration(migrations.Migration):
field=models.IntegerField(
blank=True,
default=0,
verbose_name="Number of people who have chronic diseases living with the patient",
verbose_name=_("Number of people who have chronic diseases living with the patient"),
),
),
migrations.AlterField(
model_name="patientregistration",
name="present_health",
field=models.TextField(
blank=True, default="", verbose_name="Patient's Current Health Details"
blank=True, default="", verbose_name=_("Patient's Current Health Details")
),
),
]
5 changes: 3 additions & 2 deletions care/facility/migrations_old/0068_auto_20200403_1611.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
# Generated by Django 2.2.11 on 2020-04-03 16:11

from django.db import migrations, models
Expand All @@ -15,7 +16,7 @@ class Migration(migrations.Migration):
field=models.TextField(
blank=True,
default="",
verbose_name="Already pescribed medication if any",
verbose_name=_("Already pescribed medication if any"),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Oh, look what we have here... a tiny typo.

While the translation implementation is correct, there's a small spelling error in both instances: "pescribed" should be "prescribed". I mean, who doesn't love a good spell check, right?

Apply this fix to both instances:

-                verbose_name=_("Already pescribed medication if any"),
+                verbose_name=_("Already prescribed medication if any"),

Also applies to: 28-28

),
),
migrations.AddField(
Expand All @@ -24,7 +25,7 @@ class Migration(migrations.Migration):
field=models.TextField(
blank=True,
default="",
verbose_name="Already pescribed medication if any",
verbose_name=_("Already pescribed medication if any"),
),
),
]
5 changes: 3 additions & 2 deletions care/facility/migrations_old/0071_auto_20200404_1737.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
# Generated by Django 2.2.11 on 2020-04-04 12:07

from django.db import migrations, models
Expand All @@ -23,7 +24,7 @@ class Migration(migrations.Migration):
(6, "EXPIRED"),
],
default=1,
verbose_name="Disease Status",
verbose_name=_("Disease Status"),
),
),
migrations.AlterField(
Expand All @@ -40,7 +41,7 @@ class Migration(migrations.Migration):
(6, "EXPIRED"),
],
default=1,
verbose_name="Disease Status",
verbose_name=_("Disease Status"),
),
),
]
5 changes: 3 additions & 2 deletions care/facility/migrations_old/0073_auto_20200404_2303.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Translation strings seem mostly consistent, with a slight inconsistency

I couldn't help but notice a tiny discrepancy in the medical worker string:

  • Model uses: "Is the Patient a Medical Worker"
  • Migration 0073 uses: "Is the Patient a Medical Worker" _(correctly wrapped in ())
  • Migration 0173 uses: "Is Patient a Migrant Worker" (different text altogether)

Perhaps someone got a bit creative with the string variations? The other strings are perfectly consistent though, which is... nice.

🔗 Analysis chain

Verify translation string usage

Let's ensure these new translation strings are used consistently across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of these translation strings
echo "Searching for translation string usage patterns..."
rg -l "Patient's Known Allergies|Is Patient a Migrant Worker|Is the Patient a Medical Worker" \
  --type py \
  --glob '!**/migrations/**'

Length of output: 446


Script:

#!/bin/bash
# Let's see how these strings are actually used in the model and migrations
echo "=== Checking patient.py usage ==="
rg "Patient's Known Allergies|Is Patient a Migrant Worker|Is the Patient a Medical Worker" care/facility/models/patient.py -A 2

echo -e "\n=== Checking migrations usage ==="
rg "Patient's Known Allergies|Is Patient a Migrant Worker|Is the Patient a Medical Worker" care/facility/migrations_old/0073_auto_20200404_2303.py -A 2
rg "Patient's Known Allergies|Is Patient a Migrant Worker|Is the Patient a Medical Worker" care/facility/migrations_old/0126_auto_20200626_0156.py -A 2
rg "Patient's Known Allergies|Is Patient a Migrant Worker|Is the Patient a Medical Worker" care/facility/migrations_old/0173_auto_20200903_1625.py -A 2

Length of output: 1634

🧰 Tools
🪛 Ruff (0.8.2)

1-1: Invalid module name: '0073_auto_20200404_2303'

(N999)

# Generated by Django 2.2.11 on 2020-04-04 17:33

from django.db import migrations, models
Expand All @@ -13,14 +14,14 @@ class Migration(migrations.Migration):
model_name="historicalpatientregistration",
name="is_medical_worker",
field=models.BooleanField(
default=False, verbose_name="Is the Patient a Medical Worker"
default=False, verbose_name=_("Is the Patient a Medical Worker")
),
),
migrations.AddField(
model_name="patientregistration",
name="is_medical_worker",
field=models.BooleanField(
default=False, verbose_name="Is the Patient a Medical Worker"
default=False, verbose_name=_("Is the Patient a Medical Worker")
),
),
]
3 changes: 2 additions & 1 deletion care/facility/migrations_old/0074_auto_20200404_2352.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import gettext_lazy as _
# Generated by Django 2.2.11 on 2020-04-04 18:22

from django.db import migrations, models
Expand Down Expand Up @@ -70,7 +71,7 @@ class Migration(migrations.Migration):
model_name="dailyround",
name="recommend_discharge",
field=models.BooleanField(
default=False, verbose_name="Recommend Discharging Patient"
default=False, verbose_name=_("Recommend Discharging Patient")
),
),
]
Loading