Skip to content

Commit

Permalink
Merge branch 'release/0.3.89' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 20, 2025
2 parents dc20941 + 58622f5 commit 058680c
Show file tree
Hide file tree
Showing 31 changed files with 50 additions and 56 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
3 changes: 1 addition & 2 deletions edc_adverse_event/action_items/ae_tmg_action.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.utils.html import format_html
from edc_action_item import ActionWithNotification
from edc_constants.constants import CLOSED, HIGH_PRIORITY

Expand All @@ -23,7 +22,7 @@ class AeTmgAction(ActionWithNotification):
color_style = "info"
show_link_to_changelist = True
admin_site_name = ADVERSE_EVENT_ADMIN_SITE
instructions = format_html("This report is to be completed by the TMG only.")
instructions = "This report is to be completed by the TMG only."
priority = HIGH_PRIORITY

def close_action_item_on_save(self):
Expand Down
3 changes: 1 addition & 2 deletions edc_adverse_event/action_items/death_report_tmg_action.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.utils.html import format_html
from edc_action_item.action_with_notification import ActionWithNotification
from edc_constants.constants import CLOSED, HIGH_PRIORITY, NO, YES

Expand All @@ -22,7 +21,7 @@ class DeathReportTmgAction(ActionWithNotification):
color_style = "info"
show_link_to_changelist = True
singleton = True
instructions = format_html("This report is to be completed by the TMG only.")
instructions = "This report is to be completed by the TMG only."

reference_model = f"{ADVERSE_EVENT_APP_LABEL}.deathreporttmg"
related_reference_model = f"{ADVERSE_EVENT_APP_LABEL}.deathreport"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.utils.html import format_html
from edc_action_item.action_with_notification import ActionWithNotification
from edc_constants.constants import CLOSED, HIGH_PRIORITY

Expand All @@ -21,7 +20,7 @@ class DeathReportTmgSecondAction(ActionWithNotification):
color_style = "info"
show_link_to_changelist = True
singleton = True
instructions = format_html("This report is to be completed by the TMG only.")
instructions = "This report is to be completed by the TMG only."

reference_model = f"{ADVERSE_EVENT_APP_LABEL}.deathreporttmgsecond"
related_reference_model = f"{ADVERSE_EVENT_APP_LABEL}.deathreport"
Expand Down
3 changes: 0 additions & 3 deletions edc_adverse_event/dashboard_templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from edc_dashboard.utils import insert_bootstrap_version

dashboard_templates = dict(
ae_home_template="edc_adverse_event/ae/ae_home.html",
ae_listboard_template="edc_adverse_event/ae/ae_listboard.html",
Expand All @@ -10,4 +8,3 @@
tmg_home_template="edc_adverse_event/tmg/tmg_home.html",
tmg_summary_listboard_template="edc_adverse_event/tmg/tmg_summary_listboard.html",
)
dashboard_templates = insert_bootstrap_version(**dashboard_templates)
2 changes: 0 additions & 2 deletions edc_adverse_event/locale/sw/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: edc_adverse_event/templates/edc_adverse_event/bootstrap3/ae/ae_death_report_listboard.html:38
#: edc_adverse_event/templates/edc_adverse_event/bootstrap3/tmg/tmg_death_listboard.html:29
msgid "Go to subject dashboard"
msgstr "Nenda kwenye dashibodi ya mada"
3 changes: 0 additions & 3 deletions edc_adverse_event/middleware.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from edc_dashboard.utils import insert_bootstrap_version

from .dashboard_templates import dashboard_templates
from .dashboard_urls import dashboard_urls

Expand All @@ -15,7 +13,6 @@ def __call__(self, request):
def process_view(self, request, *args):
request.url_name_data.update(**dashboard_urls)
template_data = dashboard_templates
template_data = insert_bootstrap_version(**template_data)
request.template_data.update(**template_data)

def process_template_response(self, request, response):
Expand Down
13 changes: 9 additions & 4 deletions edc_adverse_event/modeladmin_mixins/modeladmin_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,30 @@ class AdverseEventModelAdminMixin:

@display(description="subject identifier", ordering="subject_identifier")
def subject_identifier_column(self, obj=None):
return format_html(f"{obj.subject_identifier}<BR>{obj.action_identifier.upper()[-9:]}")
return format_html(
"{subject_identifier}<BR>{action_identifier}",
subject_identifier=obj.subject_identifier,
action_identifier=obj.action_identifier.upper()[-9:],
)

@display(description="User", ordering="user_created")
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)),
]
)
),
)

@display(description="Documents")
def documents_column(self, model_obj):
"""Returns a formatted list of links to AE Follow up reports."""
"""Returns a formatted list of links to AE Followup reports."""
column_items: list[ColumnItem] = []
ae_followup_model_cls = get_ae_model("aefollowup")
ae_susar_model_cls = get_ae_model("aesusar")
Expand Down Expand Up @@ -120,4 +125,4 @@ 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("{}", html)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'edc_dashboard/bootstrap3/base.html' %}
{% extends 'edc_dashboard/base.html' %}
{% load static %}
{% load edc_adverse_event_extras %}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% load i18n %}
{% trans "To find an initial adverse event report, search on the subject's study identifier or AE reference number." %}<BR>{% trans "To download the printable report, click on the PDF button" %} <i class='fas fa-file-pdf fa-fw'></i> {% trans "left of the subject's identifier." %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% load i18n %}

{% trans "To find a death report, search on the subject's study identifier, death report reference number, or AE reference number" %}<BR> {% trans "To download the printable report, click on the PDF button" %} <i class='fas fa-file-pdf fa-fw'></i> {% trans "left of the subject's identifier." %}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{% if subject_identifier %}
<a class="btn btn-sm btn-primary" role="button" title="go to list of reported visits for this subject" href="{% url subject_review_listboard_url|default:"subject_review_listboard_url_cannot_be_none" subject_identifier=subject_identifier %}?q={{ subject_identifier }}">Subject Review <i class="fas fa-share fa-fw"></i></a>
{% endif %}
{% include 'edc_dashboard/bootstrap3/search_form.html' %}
{% include 'edc_dashboard/search_form.html' %}
</span></span>

</div> <!--end panel heading -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'edc_dashboard/bootstrap3/base.html' %}
{% extends 'edc_dashboard/base.html' %}
{% load static %}
{% load edc_adverse_event_extras %}

Expand Down Expand Up @@ -43,7 +43,7 @@
<li class="list-group-item list-group-item-info">Notice</li>
<li class="list-group-item">
{% for item in notices %}
{{ item.0|title }} has {{ item.2 }} {{ item.1|lower }} AE TMG report{{ item.2|pluralize }}</BR>
{{ item.0|title }} has {{ item.2 }} {{ item.1|lower }} AE TMG report{{ item.2|pluralize }}<BR>
{% endfor %}
</li>
</ul>
Expand Down
29 changes: 14 additions & 15 deletions edc_adverse_event/templatetags/edc_adverse_event_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
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
from edc_dashboard.utils import get_bootstrap_version
from edc_model_admin.utils import add_to_messages_once
from edc_utils import escape_braces, get_utcnow

Expand Down Expand Up @@ -55,8 +54,8 @@ def wrapx(text: str, length: int) -> str:

def select_ae_template(relative_path):
"""Returns a template object."""
local_path = f"{get_adverse_event_app_label()}/bootstrap{get_bootstrap_version()}/"
default_path = f"edc_adverse_event/bootstrap{get_bootstrap_version()}/"
local_path = get_adverse_event_app_label()
default_path = "edc_adverse_event"
return select_template(
[
os.path.join(local_path, relative_path),
Expand All @@ -79,12 +78,12 @@ 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)
"{}", wrapx(escape_braces(ae_initial.sae_reason.name), wrap_length)
)
except AttributeError:
context["sae_reason"] = ""
context["ae_description"] = format_html(
wrapx(escape_braces(ae_initial.ae_description), wrap_length)
"{}", wrapx(escape_braces(ae_initial.ae_description), wrap_length)
)
return context

Expand All @@ -100,15 +99,15 @@ 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)
"{}", wrapx(escape_braces(ae_followup.ae_initial.sae_reason.name), wrap_length)
)
except AttributeError:
context["sae_reason"] = ""
context["relevant_history"] = format_html(
wrapx(escape_braces(ae_followup.relevant_history), wrap_length)
"{}", wrapx(escape_braces(ae_followup.relevant_history), wrap_length)
)
context["ae_description"] = format_html(
wrapx(escape_braces(ae_followup.ae_initial.ae_description), wrap_length)
"{}", wrapx(escape_braces(ae_followup.ae_initial.ae_description), wrap_length)
)
return context

Expand All @@ -122,19 +121,19 @@ def format_ae_susar_description(context, ae_susar, wrap_length):
context["ae_susar"] = ae_susar
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)
)
),
)
context["ae_description"] = format_html(
wrapx(escape_braces(ae_susar.ae_initial.ae_description), wrap_length)
"{}", wrapx(escape_braces(ae_susar.ae_initial.ae_description), wrap_length)
)
return context


@register.inclusion_tag(
f"edc_adverse_event/bootstrap{get_bootstrap_version()}/"
f"tmg/tmg_ae_listboard_result.html",
"edc_adverse_event/tmg/tmg_ae_listboard_result.html",
takes_context=True,
)
def tmg_listboard_results(
Expand All @@ -146,7 +145,7 @@ def tmg_listboard_results(


@register.inclusion_tag(
f"edc_adverse_event/bootstrap{get_bootstrap_version()}/tmg/death_report_tmg_panel.html",
"edc_adverse_event/tmg/death_report_tmg_panel.html",
takes_context=True,
)
def render_death_report_tmg_panel(context, action_item: ActionItem = None):
Expand Down Expand Up @@ -186,7 +185,7 @@ def ae_followup_queryset(


@register.inclusion_tag(
f"edc_adverse_event/bootstrap{get_bootstrap_version()}/tmg/ae_tmg_panel.html",
"edc_adverse_event/tmg/ae_tmg_panel.html",
takes_context=True,
)
def render_tmg_panel(
Expand Down Expand Up @@ -269,7 +268,7 @@ def get_empty_qs_message(status: str, search_term: str):


@register.inclusion_tag(
f"edc_adverse_event/bootstrap{get_bootstrap_version()}/tmg/tmg_button_group.html",
"edc_adverse_event/tmg/tmg_button_group.html",
takes_context=True,
)
def render_tmg_button_group(context, subject_identifier: str):
Expand Down
2 changes: 1 addition & 1 deletion edc_adverse_event/tests/tests/test_form_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def clean(self):
subject_identifier=self.subject_identifier,
death_date=death_report.death_datetime,
)
death_report.death_datetime = death_report.death_datetime.date()
death_report.death_datetime = death_report.death_datetime
death_report.save()
form_validator = TestFormValidator(cleaned_data=data, model=DeathReportTmg)
try:
Expand Down
14 changes: 6 additions & 8 deletions edc_adverse_event/view_mixins/ae/ae_listboard_view_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from typing import TYPE_CHECKING, Any

from django.core.exceptions import ObjectDoesNotExist
from django.template.loader import render_to_string
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from edc_constants.constants import CLOSED, NEW, OPEN
from edc_dashboard.view_mixins import EdcViewMixin
from edc_listboard.view_mixins import ListboardFilterViewMixin, SearchFormViewMixin
Expand Down Expand Up @@ -39,14 +41,10 @@ class AeListboardViewMixin(
listboard_view_permission_codename = "edc_adverse_event.view_ae_listboard"

listboard_instructions = format_html(
(
"To find an initial adverse event report, search on the subject's "
"study identifier or AE reference number."
)
+ " <BR>"
+ "To download the printable report, click on the PDF button"
+ " <i class='fas fa-file-pdf fa-fw'></i> "
+ "left of the subject's identifier."
"{}",
mark_safe(
render_to_string("edc_adverse_event/ae/ae_listboard_instructions.html")
), # nosec B703 B308,
)
navbar_selected_item = "ae_home"
ordering = "-report_datetime"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from django.core.exceptions import ObjectDoesNotExist
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from edc_constants.constants import CLOSED, NEW, OPEN
from edc_dashboard.view_mixins import EdcViewMixin
from edc_listboard.view_mixins import ListboardFilterViewMixin, SearchFormViewMixin
Expand Down Expand Up @@ -37,11 +38,10 @@ class DeathReportListboardViewMixin(
listboard_panel_title = "Adverse Events: Death Reports"
listboard_view_permission_codename = "edc_adverse_event.view_ae_listboard"
listboard_instructions = format_html(
"To find a death report, search on the subject's "
"study identifier, death report reference number, or AE reference number."
"<BR>To download the printable report, click on the PDF button"
"<i class='fas fa-file-pdf fa-fw'></i> "
"left of the subject's identifier."
"{}",
mark_safe(
"edc_adverse_enet/ae/death_report_listboard_instructions.html"
), # nosec B703 B308
)

navbar_selected_item = "ae_home"
Expand Down
3 changes: 1 addition & 2 deletions edc_adverse_event/views/home_view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any

from django.conf import settings
from django.urls import reverse
from django.views.generic import TemplateView
from edc_dashboard.url_names import url_names
Expand All @@ -14,7 +13,7 @@ class AeHomeView(UrlRequestContextMixin, EdcViewMixin, NavbarViewMixin, Template
ae_listboard_url = "ae_listboard_url"
death_report_listboard_url = "death_report_listboard_url"
navbar_selected_item = "ae_home"
template_name = f"edc_adverse_event/bootstrap{settings.EDC_BOOTSTRAP}/ae/ae_home.html"
template_name = "edc_adverse_event/ae/ae_home.html"
url_name = "ae_home_url"

def get_context_data(self, **kwargs) -> dict[str, Any]:
Expand Down
3 changes: 1 addition & 2 deletions edc_adverse_event/views/tmg/home_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from django.views.generic import TemplateView
from edc_action_item.models.action_item import ActionItem
from edc_constants.constants import CLOSED, NEW, OPEN
from edc_dashboard.utils import get_bootstrap_version
from edc_dashboard.view_mixins import EdcViewMixin
from edc_navbar import NavbarViewMixin

Expand All @@ -15,7 +14,7 @@


class TmgHomeView(EdcViewMixin, NavbarViewMixin, TemplateView):
template_name = f"edc_adverse_event/bootstrap{get_bootstrap_version()}/tmg/tmg_home.html"
template_name = "edc_adverse_event/tmg/tmg_home.html"
navbar_selected_item = "tmg_home"

def get_context_data(self, **kwargs) -> dict[str, Any]:
Expand Down

0 comments on commit 058680c

Please sign in to comment.