From f6ac2f9110b031db379ed47c3aa748accefb6677 Mon Sep 17 00:00:00 2001 From: erikvw Date: Tue, 21 Jan 2025 21:30:56 -0600 Subject: [PATCH] format_html, mark_safe, translations --- edc_qol/choices.py | 171 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 151 insertions(+), 20 deletions(-) diff --git a/edc_qol/choices.py b/edc_qol/choices.py index 4c95683..4bc64d3 100644 --- a/edc_qol/choices.py +++ b/edc_qol/choices.py @@ -1,5 +1,6 @@ from django.utils.functional import lazy from django.utils.html import format_html +from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ from .constants import ( @@ -103,67 +104,197 @@ ( "4", format_html_lazy( - _("I am able to feel settled and secure in all areas of my life") + "{}", + mark_safe( + _("I am able to feel settled and secure in all areas of my life") + ), # nosec B703, B308 ), ), ( "3", format_html_lazy( - _("I am able to feel settled and secure in many areas of my life") + "{}", + mark_safe( + _("I am able to feel settled and secure in many areas of my life") + ), # nosec B703, B308 ), ), ( "2", format_html_lazy( - _("I am able to feel settled and secure in a few areas of my life") + "{}", + mark_safe( + _("I am able to feel settled and secure in a few areas of my life") + ), # nosec B703, B308 ), ), ( "1", format_html_lazy( - _("I am unable to feel settled and secure in any areas of my life") + "{}", + mark_safe( + _( + "I am unable to feel settled and secure in any " + "areas of my life" + ) + ), # nosec B703, B308 ), ), ) ICECAP_ATTACHMENT = ( - ("4", format_html_lazy(_("I can have a lot of love, friendship and support"))), + ( + "4", + format_html_lazy( + "{}", + mark_safe( + _("I can have a lot of love, friendship and support") + ), # nosec B703, B308 + ), + ), ( "3", - format_html_lazy(_("I can have quite a lot of love, friendship and support")), + format_html_lazy( + "{}", + mark_safe( + _("I can have quite a lot of love, friendship and support") + ), # nosec B703, B308 + ), + ), + ( + "2", + format_html_lazy( + "{}", + mark_safe( + _("I can have a little love, friendship and support") + ), # nosec B703, B308 + ), + ), + ( + "1", + format_html_lazy( + "{}", + mark_safe( + _("I cannot have any love, friendship and support") + ), # nosec B703, B308 + ), ), - ("2", format_html_lazy(_("I can have a little love, friendship and support"))), - ("1", format_html_lazy(_("I cannot have any love, friendship and support"))), ) ICECAP_AUTONOMY = ( - ("4", format_html_lazy(_("I am able to be completely independent"))), - ("3", format_html_lazy(_("I am able to be independent in many things"))), - ("2", format_html_lazy(_("I am able to be independent in a few things"))), - ("1", format_html_lazy(_("I am unable to be at all independent"))), + ( + "4", + format_html_lazy( + "{}", + mark_safe(_("I am able to be completely independent")), # nosec B703, B308 + ), + ), + ( + "3", + format_html_lazy( + "{}", + mark_safe( + _("I am able to be independent in many things") + ), # nosec B703, B308 + ), + ), + ( + "2", + format_html_lazy( + "{}", + mark_safe( + _("I am able to be independent in a few things") + ), # nosec B703, B308 + ), + ), + ( + "1", + format_html_lazy( + "{}", + mark_safe(_("I am unable to be at all independent")), # nosec B703, B308 + ), + ), ) ICECAP_ACHIEVMENT = ( - ("4", format_html_lazy(_("I can achieve and progress in all aspects of my life"))), - ("3", format_html_lazy(_("I can achieve and progress in many aspects of my life"))), + ( + "4", + format_html_lazy( + "{}", + mark_safe( + _("I can achieve and progress in all aspects of my life") + ), # nosec B703, B308 + ), + ), + ( + "3", + format_html_lazy( + "{}", + mark_safe( + _("I can achieve and progress in many aspects of my life") + ), # nosec B703, B308 + ), + ), ( "2", - format_html_lazy(_("I can achieve and progress in a few aspects of my life")), + format_html_lazy( + "{}", + mark_safe( + _("I can achieve and progress in a few aspects of my life") + ), # nosec B703, B308 + ), ), ( "1", format_html_lazy( - _("I cannot achieve and progress in any aspects of my life") + "{}", + mark_safe( + _( + "I cannot achieve and progress in any aspects of my life" + ), # nosec B703, B308 + ), ), ), ) ICECAP_ENJOYMENT = ( - ("4", format_html_lazy(_("I can have a lot of enjoyment and pleasure"))), - ("3", format_html_lazy(_("I can have quite a lot of enjoyment and pleasure"))), - ("2", format_html_lazy(_("I can have a little enjoyment and pleasure"))), - ("1", format_html_lazy(_("I cannot have any enjoyment and pleasure"))), + ( + "4", + format_html_lazy( + "{}", + mark_safe( + _("I can have a lot of enjoyment and pleasure") + ), # nosec B703, B308 + ), + ), + ( + "3", + format_html_lazy( + "{}", + mark_safe( + _("I can have quite a lot of enjoyment and pleasure") + ), # nosec B703, B308 + ), + ), + ( + "2", + format_html_lazy( + "{}", + mark_safe( + _("I can have a little enjoyment and pleasure") + ), # nosec B703, B308 + ), + ), + ( + "1", + format_html_lazy( + "{}", + mark_safe( + _("I cannot have any enjoyment and pleasure") + ), # nosec B703, B308 + ), + ), )