Skip to content

Commit

Permalink
Merge branch 'release/1.0.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 22, 2025
2 parents ce99fe9 + c926309 commit a8adc13
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exclude: tests/etc/user-*

repos:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
rev: 1.8.2
hooks:
- id: bandit
args:
Expand Down
34 changes: 23 additions & 11 deletions edc_qol/admin/sf12_admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django_audit_fields.admin import audit_fieldset_tuple
from edc_model_admin.dashboard import ModelAdminSubjectDashboardMixin
from edc_model_admin.history import SimpleHistoryAdmin
Expand All @@ -9,13 +10,16 @@
from ..models import Sf12

additional_instructions = format_html(
"<p>"
"This survey asks for your views about your health. This information "
"will help keep track of how you feel and how well you are able to do "
"your usual activities. "
"<b>Answer each question by choosing just one answer</b>. If you are "
"unsure how to answer a question, please give the best answer you can."
"</p>"
"{}",
mark_safe( # nosec B308, B703
"<p>"
"This survey asks for your views about your health. This information "
"will help keep track of how you feel and how well you are able to do "
"your usual activities. "
"<b>Answer each question by choosing just one answer</b>. If you are "
"unsure how to answer a question, please give the best answer you can."
"</p>"
),
)

past_4w = "<u>past 4 weeks</u>"
Expand Down Expand Up @@ -61,7 +65,9 @@ def sf12_fieldsets():
(
"Part 2: Activities limited by health",
{
"description": format_html(part2_description),
"description": format_html(
"{}", mark_safe(part2_description) # nosec B308, B703
),
"fields": (
"moderate_activities_now_limited",
"climbing_stairs_now_limited",
Expand All @@ -71,7 +77,9 @@ def sf12_fieldsets():
(
"Part 3: Physical health problems (last 4 weeks)",
{
"description": format_html(part3_description),
"description": format_html(
"{}", mark_safe(part3_description) # nosec B308, B703
),
"fields": (
"accomplished_less_physical_health",
"work_limited_physical_health",
Expand All @@ -81,7 +89,9 @@ def sf12_fieldsets():
(
"Part 4: Emotional problems (last 4 weeks)",
{
"description": format_html(part4_description),
"description": format_html(
"{}", mark_safe(part4_description) # nosec B308, B703
),
"fields": (
"accomplished_less_emotional",
"work_less_carefully_emotional",
Expand All @@ -95,7 +105,9 @@ def sf12_fieldsets():
(
"Part 6: Feeling (last 4 weeks)",
{
"description": format_html(part6_description),
"description": format_html(
"{}", mark_safe(part6_description) # nosec B308, B703
),
"fields": (
"felt_calm_peaceful",
"felt_lot_energy",
Expand Down
38 changes: 25 additions & 13 deletions edc_qol/model_mixins/eq5d3l_model_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.core.validators import MaxValueValidator, MinValueValidator
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 @@ -17,39 +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(
"<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")
61 changes: 43 additions & 18 deletions edc_qol/model_mixins/sf12_model_mixin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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_lazy as _
from edc_constants.choices import YES_NO

Expand All @@ -21,55 +22,76 @@ class Sf12ModelMixin(models.Model):

moderate_activities_now_limited = models.CharField(
verbose_name=format_html(
_(
"<u>Moderate activities</u> such as moving a table, "
"pushing a vacuum cleaner, bowling, or playing golf:"
)
"{}",
mark_safe( # nosec B308, B703
_(
"<u>Moderate activities</u> such as moving a table, "
"pushing a vacuum cleaner, bowling, or playing golf:"
)
),
),
max_length=20,
choices=HEALTH_LIMITED_CHOICES,
)

climbing_stairs_now_limited = models.CharField(
verbose_name=format_html(_("Climbing <u>several</u> flights of stairs:")),
verbose_name=format_html(
"{}",
mark_safe(_("Climbing <u>several</u> flights of stairs:")), # nosec B308, B703
),
max_length=20,
choices=HEALTH_LIMITED_CHOICES,
)

accomplished_less_physical_health = models.CharField(
verbose_name=format_html(_("<u>Accomplished less</u> than you would like:")),
verbose_name=format_html(
"{}",
mark_safe(_("<u>Accomplished less</u> than you would like:")), # nosec B308, B703
),
max_length=15,
choices=YES_NO,
)

work_limited_physical_health = models.CharField(
verbose_name=format_html(
_("Were limited in the <u>kind</u> of work or other activities:")
"{}",
mark_safe( # nosec B308, B703
_("Were limited in the <u>kind</u> of work or other activities:")
),
),
max_length=15,
choices=YES_NO,
)

accomplished_less_emotional = models.CharField(
verbose_name=format_html(_("<u>Accomplished less</u> than you would like:")),
verbose_name=format_html(
"{}",
mark_safe(_("<u>Accomplished less</u> than you would like:")), # nosec B308, B703
),
max_length=15,
choices=YES_NO,
)

work_less_carefully_emotional = models.CharField(
verbose_name=format_html(
_("Did work or activities <u>less carefully than usual</u>:")
"{}",
mark_safe( # nosec B308, B703
_("Did work or activities <u>less carefully than usual</u>:")
),
),
max_length=15,
choices=YES_NO,
)

pain_interfere_work = models.CharField(
verbose_name=format_html(
_(
"During the <u>past 4 weeks</u>, how much <u>did pain interfere</u> "
"with your normal work (including work outside the home and housework)?"
)
"{}",
mark_safe( # nosec B308, B703
_(
"During the <u>past 4 weeks</u>, how much <u>did pain interfere</u> "
"with your normal work (including work outside the home and housework)?"
)
),
),
max_length=15,
choices=WORK_PAIN_INTERFERENCE_CHOICES,
Expand All @@ -95,11 +117,14 @@ class Sf12ModelMixin(models.Model):

social_activities_interfered = models.CharField(
verbose_name=format_html(
_(
"During the <u>past 4 weeks</u>, how much of the time has your physical "
"health or emotional problems interfered with your social "
"activities (like visiting friends, relatives, etc.)?"
)
"{}",
mark_safe( # nosec B308, B703
_(
"During the <u>past 4 weeks</u>, how much of the time has your physical "
"health or emotional problems interfered with your social "
"activities (like visiting friends, relatives, etc.)?"
)
),
),
max_length=25,
choices=INTERFERENCE_DURATION_CHOICES,
Expand Down
5 changes: 4 additions & 1 deletion edc_qol/modeladmin_mixins/eq5d3l_model_admin_mixin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django_audit_fields.admin import audit_fieldset_tuple

eq5d3l_description = """
Expand Down Expand Up @@ -36,7 +37,9 @@ def eq5d3l_fieldsets():
(
"How is your health TODAY?",
{
"description": format_html(eq5d3l_description),
"description": format_html(
"{}", mark_safe(eq5d3l_description) # nosec B308, B703
),
"fields": (
"health_today_score_slider",
"health_today_score_confirmed",
Expand Down
60 changes: 60 additions & 0 deletions edc_qol/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import sys
from pathlib import Path

from edc_test_settings.default_test_settings import DefaultTestSettings

app_name = "edc_qol"
base_dir = Path(__file__).absolute().parent.parent.parent

project_settings = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
APP_NAME=app_name,
SILENCED_SYSTEM_CHECKS=[
"sites.E101",
"edc_navbar.E003",
"edc_consent.E001",
"edc_sites.E001",
"edc_sites.E002",
],
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
EDC_AUTH_SKIP_SITE_AUTHS=True,
EDC_AUTH_SKIP_AUTH_UPDATER=True,
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"multisite",
"django_crypto_fields.apps.AppConfig",
"django_revision.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_auth.apps.AppConfig",
"edc_dashboard.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_list_data.apps.AppConfig",
"edc_listboard.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_navbar.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_review_dashboard.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_subject_dashboard.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_qol.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
add_dashboard_middleware=True,
).settings

for k, v in project_settings.items():
setattr(sys.modules[__name__], k, v)
Loading

0 comments on commit a8adc13

Please sign in to comment.