Skip to content

Commit

Permalink
Merge branch 'release/1.0.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 22, 2025
2 parents 29c70da + 0aa0da5 commit 6f39156
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
27 changes: 18 additions & 9 deletions edc_adverse_event/modeladmin_mixins/modeladmin_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ def user(self, obj=None):
"""Returns formatted usernames and creation/modification dates."""
return format_html(
"{}",
"<BR>".join(
[
obj.user_created,
obj.created.strftime(convert_php_dateformat(settings.SHORT_DATE_FORMAT)),
obj.user_modified,
obj.modified.strftime(convert_php_dateformat(settings.SHORT_DATE_FORMAT)),
]
),
mark_safe(
"<BR>".join(
[
obj.user_created,
obj.created.strftime(
convert_php_dateformat(settings.SHORT_DATE_FORMAT)
),
obj.user_modified,
obj.modified.strftime(
convert_php_dateformat(settings.SHORT_DATE_FORMAT)
),
]
),
), # nosec B703, B308
)

@display(description="Documents")
Expand Down Expand Up @@ -125,4 +131,7 @@ def documents_column(self, model_obj):
html = "<table><tr><td>"
html += "</td><tr><td>".join([c.anchor for c in column_items])
html += "</td></td></table>"
return format_html("{}", html)
return format_html(
"{}",
mark_safe(html), # nosec B703, B308
)
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def raise_if_followup_exists(self):
'{} instead. See <A href="{}">AE Follow-ups for {}</A>.',
ae_followup_cls._meta.verbose_name,
mark_safe(url), # nosec B703, B308
mark_safe(self.instance), # nosec B703, B308
mark_safe(str(self.instance)), # nosec B703, B308
)
)

Expand Down
39 changes: 30 additions & 9 deletions edc_adverse_event/templatetags/edc_adverse_event_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django.template.loader import select_template
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
from edc_action_item.utils import get_reference_obj
from edc_constants.constants import CLOSED, OPEN, OTHER, YES
Expand Down Expand Up @@ -78,12 +79,18 @@ def format_ae_description(context, ae_initial, wrap_length):
context["ae_initial"] = ae_initial
try:
context["sae_reason"] = format_html(
"{}", wrapx(escape_braces(ae_initial.sae_reason.name), wrap_length)
"{}",
mark_safe(
wrapx(escape_braces(ae_initial.sae_reason.name), wrap_length)
), # nosec B703, B308
)
except AttributeError:
context["sae_reason"] = ""
context["ae_description"] = format_html(
"{}", wrapx(escape_braces(ae_initial.ae_description), wrap_length)
"{}",
mark_safe(
wrapx(escape_braces(ae_initial.ae_description), wrap_length)
), # nosec B703, B308
)
return context

Expand All @@ -99,15 +106,24 @@ def format_ae_followup_description(context, ae_followup, wrap_length):
context["ae_initial"] = ae_followup.ae_initial
try:
context["sae_reason"] = format_html(
"{}", wrapx(escape_braces(ae_followup.ae_initial.sae_reason.name), wrap_length)
"{}",
mark_safe(
wrapx(escape_braces(ae_followup.ae_initial.sae_reason.name), wrap_length)
), # nosec B703, B308
)
except AttributeError:
context["sae_reason"] = ""
context["relevant_history"] = format_html(
"{}", wrapx(escape_braces(ae_followup.relevant_history), wrap_length)
"{}",
mark_safe(
wrapx(escape_braces(ae_followup.relevant_history), wrap_length)
), # nosec B703, B308
)
context["ae_description"] = format_html(
"{}", wrapx(escape_braces(ae_followup.ae_initial.ae_description), wrap_length)
"{}",
mark_safe(
wrapx(escape_braces(ae_followup.ae_initial.ae_description), wrap_length)
), # nosec B703, B308
)
return context

Expand All @@ -122,12 +138,17 @@ def format_ae_susar_description(context, ae_susar, wrap_length):
context["ae_initial"] = ae_susar.ae_initial
context["sae_reason"] = format_html(
"{}",
"<BR>".join(
wrap(escape_braces(ae_susar.ae_initial.sae_reason.name), wrap_length or 35)
),
mark_safe(
"<BR>".join(
wrap(escape_braces(ae_susar.ae_initial.sae_reason.name), wrap_length or 35)
)
), # nosec B703, B308
)
context["ae_description"] = format_html(
"{}", wrapx(escape_braces(ae_susar.ae_initial.ae_description), wrap_length)
"{}",
mark_safe(
wrapx(escape_braces(ae_susar.ae_initial.ae_description), wrap_length)
), # nosec B703, B308
)
return context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DeathReportListboardViewMixin(
listboard_instructions = format_html(
"{}",
mark_safe(
"edc_adverse_enet/ae/death_report_listboard_instructions.html"
"edc_adverse_event/ae/death_report_listboard_instructions.html"
), # nosec B703 B308
)

Expand Down

0 comments on commit 6f39156

Please sign in to comment.