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 0e5104c commit c926309
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions edc_qol/model_mixins/eq5d3l_model_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.db import models
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _

from ..choices import (
ANXIETY_DEPRESSION,
Expand All @@ -18,42 +19,49 @@ class Eq5d3lModelMixin(models.Model):
self_care = models.CharField(verbose_name="Self-care", max_length=45, choices=SELF_CARE)

usual_activities = models.CharField(
verbose_name="Usual activities",
verbose_name=_("Usual activities"),
max_length=45,
help_text="Example. work, study, housework, family or leisure activities",
help_text=_("Example. work, study, housework, family or leisure activities"),
choices=USUAL_ACTIVITIES,
)

pain_discomfort = models.CharField(
verbose_name="Pain / Discomfort", max_length=45, choices=PAIN_DISCOMFORT
verbose_name=_("Pain / Discomfort"), max_length=45, choices=PAIN_DISCOMFORT
)

anxiety_depression = models.CharField(
verbose_name="Anxiety / Depression", max_length=45, choices=ANXIETY_DEPRESSION
verbose_name=_("Anxiety / Depression"), max_length=45, choices=ANXIETY_DEPRESSION
)

health_today_score_slider = models.CharField(
verbose_name=format_html("{}", "Visual score for how your health is TODAY"),
verbose_name=_("Visual score for how your health is TODAY"),
max_length=3,
)

health_today_score_confirmed = models.IntegerField(
verbose_name=format_html(
"{}",
mark_safe( # nosec B308, B703
"<B><font color='orange'>Interviewer</font></B>: "
"please confirm the number on the scale indicated from above."
),
mark_safe(
_(
"<B><font color='orange'>Interviewer</font></B>: "
"please confirm the number on the scale indicated from above."
)
), # nosec B308, B703
),
validators=[MinValueValidator(0), MaxValueValidator(100)],
help_text=(
"This scale is numbered from 0 to 100. "
"100 means the <U>best</U> health you can imagine"
"0 means the <U>worst</U> health you can imagine."
help_text=format_html(
"{}",
mark_safe(
_(
"This scale is numbered from 0 to 100. "
"100 means the <U>best</U> health you can imagine"
"0 means the <U>worst</U> health you can imagine."
)
), # nosec B308, B703
),
)

class Meta:
abstract = True
verbose_name = "EuroQol EQ-5D-3L Instrument"
verbose_name_plural = "EuroQol EQ-5D-3L Instrument"
verbose_name = _("EuroQol EQ-5D-3L Instrument")
verbose_name_plural = _("EuroQol EQ-5D-3L Instrument")

0 comments on commit c926309

Please sign in to comment.