Skip to content

Commit

Permalink
format_html, mark_safe, translations
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 22, 2025
1 parent 022498e commit 48cd230
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions edc_consent/field_mixins/citizen_fields_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CitizenFieldsMixin(models.Model):

legal_marriage = models.CharField(
verbose_name=(
"If not a citizen, is the participant " "legally married to a Botswana citizen?"
"If not a citizen, is the participant legally married to a Botswana citizen?"
),
max_length=3,
choices=YES_NO_NA,
Expand All @@ -24,7 +24,7 @@ class CitizenFieldsMixin(models.Model):

marriage_certificate = models.CharField(
verbose_name=(
"[Interviewer] Has the participant produced the marriage " "certificate as proof? "
"[Interviewer] Has the participant produced the marriage certificate as proof? "
),
max_length=3,
choices=YES_NO_NA,
Expand Down
7 changes: 4 additions & 3 deletions edc_consent/field_mixins/personal_fields_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.validators import RegexValidator
from django.db import models
from django.utils.html import format_html
from django.utils.translation import gettext as _
from django_crypto_fields.fields import EncryptedCharField
from django_crypto_fields.models import CryptoMixin
from edc_constants.choices import GENDER_UNDETERMINED
Expand Down Expand Up @@ -31,9 +32,9 @@ class BaseFieldsMixin(models.Model):
blank=True,
null=True,
help_text=format_html(
"{}.<BR>{}",
"Required only if participant is a minor",
"Format is 'LASTNAME, FIRSTNAME'. All uppercase separated by a comma.",
"{text1}.<BR>{text2}",
text1=_("Required only if participant is a minor"),
text2=_("Format is 'LASTNAME, FIRSTNAME'. All uppercase separated by a comma."),
),
)

Expand Down
5 changes: 3 additions & 2 deletions edc_consent/field_mixins/sample_collection_fields_mixin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.db import models
from django.utils.translation import gettext as _
from edc_constants.choices import YES_NO


class SampleCollectionFieldsMixin(models.Model):
may_store_genetic_samples = models.CharField(
verbose_name=(
verbose_name=_(
"Does the participant agree that a portion of "
"the blood sample that is taken be stored for genetic "
"analysis?"
Expand All @@ -14,7 +15,7 @@ class SampleCollectionFieldsMixin(models.Model):
)

may_store_samples = models.CharField(
verbose_name=(
verbose_name=_(
"Does the participant agree to have samples stored after the study has ended"
),
max_length=3,
Expand Down
21 changes: 11 additions & 10 deletions edc_consent/field_mixins/vulnerability_fields_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.conf import settings
from django.db import models
from django.utils.html import format_html
from django.utils.translation import gettext as _
from django_crypto_fields.fields import LastnameField
from django_crypto_fields.models import CryptoMixin
from edc_constants.choices import YES_NO
Expand All @@ -10,41 +11,41 @@

class VulnerabilityFieldsMixin(CryptoMixin, models.Model):
is_incarcerated = models.CharField(
verbose_name="Is the participant under involuntary incarceration?",
verbose_name=_("Is the participant under involuntary incarceration?"),
max_length=3,
choices=YES_NO,
validators=[eligible_if_no],
null=True,
help_text="( if 'Yes' STOP participant cannot be consented )",
help_text=_("If 'Yes' STOP participant cannot be consented."),
)

is_literate = models.CharField(
verbose_name="Is the participant literate?",
verbose_name=_("Is the participant literate?"),
max_length=3,
choices=YES_NO,
help_text=(
help_text=_(
"If 'No' provide witness's name on this "
"form and signature on the paper document."
),
)

witness_name = LastnameField(
verbose_name="Witness's last and first name",
verbose_name=_("Witness's last and first name"),
validators=[FullNameValidator()],
blank=True,
null=True,
help_text=format_html(
"{}.<br>{}",
"Required only if participant is illiterate",
"Format is 'LASTNAME, FIRSTNAME'. All uppercase separated by a comma.",
"{text1}.<BR>{text2}",
text1="Required only if participant is illiterate",
text2="Format is 'LASTNAME, FIRSTNAME'. All uppercase separated by a comma.",
),
)

language = models.CharField(
verbose_name="Language of consent",
verbose_name=_("Language of consent"),
max_length=25,
choices=settings.LANGUAGES,
help_text=(
help_text=_(
"The language used for the consent process will "
"also be used during data collection."
),
Expand Down

0 comments on commit 48cd230

Please sign in to comment.