Skip to content

Commit 9048ae7

Browse files
committed
Fix some bugs.
1 parent f0ed8cd commit 9048ae7

6 files changed

Lines changed: 31 additions & 24 deletions

File tree

hypha/addressfield/fields.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from django import forms
55
from django.core.exceptions import ValidationError
6-
from django.utils.translation import gettext as _
6+
from django.utils.translation import gettext_lazy as _
77

88
from .widgets import AddressWidget
99

@@ -60,7 +60,9 @@ def clean(self, value, **kwargs):
6060
if missing_fields:
6161
missing_field_name = [fields[field]["label"] for field in missing_fields]
6262
raise ValidationError(
63-
_("Please provide data for: {}").format(", ".join(missing_field_name))
63+
_("Please provide data for: {fields}").format(
64+
fields=", ".join(missing_field_name)
65+
)
6466
)
6567

6668
return super().clean(value, **kwargs)

hypha/apply/activity/models.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
from django.urls import reverse
1313
from django.utils import timezone
1414
from django.utils.text import get_valid_filename
15-
from django.utils.translation import gettext as _
16-
from django.utils.translation import gettext_lazy
15+
from django.utils.translation import gettext_lazy as _
1716

1817
from hypha.apply.utils.storage import PrivateStorage
1918

@@ -177,8 +176,8 @@ class ActivityAttachment(models.Model):
177176
)
178177

179178
class Meta:
180-
verbose_name = gettext_lazy("activity attachment")
181-
verbose_name_plural = gettext_lazy("activity attachments")
179+
verbose_name = _("activity attachment")
180+
verbose_name_plural = _("activity attachments")
182181

183182
@property
184183
def filename(self):
@@ -206,9 +205,9 @@ class Activity(models.Model):
206205
source_object_id = models.PositiveIntegerField(blank=True, null=True, db_index=True)
207206
source = GenericForeignKey("source_content_type", "source_object_id")
208207

209-
message = models.TextField(gettext_lazy("message"))
208+
message = models.TextField(_("message"))
210209
visibility = models.CharField(
211-
gettext_lazy("visibility"),
210+
_("visibility"),
212211
choices=list(VISIBILITY.items()),
213212
default=APPLICANT,
214213
max_length=30,
@@ -240,8 +239,8 @@ class Activity(models.Model):
240239
class Meta:
241240
ordering = ["-timestamp"]
242241
base_manager_name = "objects"
243-
verbose_name = gettext_lazy("activity")
244-
verbose_name_plural = gettext_lazy("activities")
242+
verbose_name = _("activity")
243+
verbose_name_plural = _("activities")
245244

246245
def get_absolute_url(self):
247246
# coverup for both submission and project as source.
@@ -341,8 +340,8 @@ class Event(models.Model):
341340
source = GenericForeignKey("content_type", "object_id")
342341

343342
class Meta:
344-
verbose_name = gettext_lazy("event")
345-
verbose_name_plural = gettext_lazy("events")
343+
verbose_name = _("event")
344+
verbose_name_plural = _("events")
346345

347346
def __str__(self):
348347
if self.source and hasattr(self.source, "title"):
@@ -380,8 +379,8 @@ class Message(models.Model):
380379
objects = MessagesQueryset.as_manager()
381380

382381
class Meta:
383-
verbose_name = gettext_lazy("message")
384-
verbose_name_plural = gettext_lazy("messages")
382+
verbose_name = _("message")
383+
verbose_name_plural = _("messages")
385384

386385
def __str__(self):
387386
return f"[{self.type}][{self.status}] {self.content}"

hypha/apply/funds/admin_forms.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ def clean(self):
2424
if number_of_stages == 1:
2525
self.validate_stages_equal_forms(workflow, application_forms)
2626
self.validate_stages_equal_forms(
27-
workflow, review_forms, form_type="Review form"
27+
workflow, review_forms, form_type=_("Review form")
2828
)
2929
self.validate_stages_equal_forms(
30-
workflow, external_review_forms, form_type="External Review form"
30+
workflow,
31+
external_review_forms,
32+
form_type=_("External review form"),
33+
optional=True,
3134
)
3235
self.validate_stages_equal_forms(
33-
workflow, determination_forms, form_type="Determination form"
36+
workflow, determination_forms, form_type=_("Determination form")
3437
)
3538

3639
if settings.PROJECTS_ENABLED:
@@ -68,7 +71,9 @@ def validate_application_forms(self, workflow, forms):
6871
error_list,
6972
)
7073

71-
def validate_stages_equal_forms(self, workflow, forms, form_type=None):
74+
def validate_stages_equal_forms(
75+
self, workflow, forms, form_type=None, optional=False
76+
):
7277
if form_type is None:
7378
form_type = _("form")
7479

@@ -81,7 +86,7 @@ def validate_stages_equal_forms(self, workflow, forms, form_type=None):
8186
plural_stage = "s" if number_of_stages > 1 else ""
8287

8388
# External Review Form is optional and should be single if provided
84-
if form_type == _("External Review form"):
89+
if optional:
8590
if number_of_forms > 1:
8691
self.add_error(
8792
None,

hypha/apply/funds/blocks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from django import forms
44
from django.utils.formats import get_format
5+
from django.utils.text import format_lazy
56
from django.utils.translation import gettext_lazy as _
67
from django.utils.translation import ngettext_lazy
78
from wagtail import blocks
@@ -228,13 +229,13 @@ class DurationBlock(ApplicationSingleIncludeFieldBlock):
228229
(MONTHS, _("Months")),
229230
)
230231
DURATION_DAY_OPTIONS = {
231-
i: ngettext_lazy("{} day", "{} days", i).format(i) for i in range(1, 8)
232+
i: format_lazy(ngettext_lazy("{} day", "{} days", i), i) for i in range(1, 8)
232233
}
233234
DURATION_WEEK_OPTIONS = {
234-
i: ngettext_lazy("{} week", "{} weeks", i).format(i) for i in range(1, 13)
235+
i: format_lazy(ngettext_lazy("{} week", "{} weeks", i), i) for i in range(1, 13)
235236
}
236237
DURATION_MONTH_OPTIONS = {
237-
i: ngettext_lazy("{} month", "{} months", i).format(i)
238+
i: format_lazy(ngettext_lazy("{} month", "{} months", i), i)
238239
for i in [*range(1, 13), 18, 24, 36]
239240
}
240241
field_class = forms.ChoiceField

hypha/apply/funds/migrations/0103_alter_screeningstatus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Migration(migrations.Migration):
1212
migrations.AlterModelOptions(
1313
name="screeningstatus",
1414
options={
15-
"verbose_name": "Screening Decision",
15+
"verbose_name": "Screening decision",
1616
"verbose_name_plural": "screening decisions",
1717
},
1818
),

hypha/apply/funds/models/screening.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ScreeningStatus(models.Model):
2020
base_form_class = ScreeningStatusAdminForm
2121

2222
class Meta:
23-
verbose_name = _("Screening Decision")
23+
verbose_name = _("Screening decision")
2424
verbose_name_plural = _("screening decisions")
2525

2626
def __str__(self):

0 commit comments

Comments
 (0)