Skip to content

Commit

Permalink
fix AETMG add not showing on tmg dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 30, 2025
1 parent 6f39156 commit 214c9c8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,33 @@

<div class="list-group">
{# AE TMG #}
<div class="list-group-item list-group-item-default"><i class="fa-solid fa-folder-tree fa-fw"></i> TMG documents in workflow</div>
<div class="list-group-item list-group-item-default"><i class="fa-solid fa-folder-tree fa-fw"></i> TMG documents in workflow </div>
{% render_tmg_panel action_item=result by_user_created_only=True counter=forloop.counter report_status=result.reference_obj.report_status next_url_name=listboard_filter_url %}

{% death_report_tmg_queryset action_item=result as qs %}
{% for death_report_tmg in qs %}
{% render_tmg_panel reference_obj=death_report_tmg by_user_created_only=True counter=forloop.counter next_url_name=listboard_filter_url %}
{% endfor %}
{% if qs.count == 0 %}
{% death_report_tmg_action_item subject_identifier=result.subject_identifier as tmg_action_item %}
{% if tmg_action_item %}
{% render_tmg_panel action_item=tmg_action_item by_user_created_only=True counter=forloop.counter report_status=result.reference_obj.report_status next_url_name=listboard_filter_url %}
{% endif %}
{% else %}
{% for death_report_tmg in qs %}
{% render_tmg_panel reference_obj=death_report_tmg by_user_created_only=True counter=forloop.counter next_url_name=listboard_filter_url %}
{% endfor %}
{% endif %}

{% death_report_tmg2_queryset action_item=result as qs %}
{% for death_report_tmg2 in qs %}
{% render_tmg_panel reference_obj=death_report_tmg2 by_user_created_only=True counter=forloop.counter next_url_name=listboard_filter_url %}
{% endfor %}
{% if qs.count == 0 %}
{% death_report_tmg_second_action_item subject_identifier=result.subject_identifier as tmg_action_item %}
{% if tmg_action_item %}
{% render_tmg_panel action_item=tmg_action_item by_user_created_only=True counter=forloop.counter report_status=result.reference_obj.report_status next_url_name=listboard_filter_url %}
{% endif %}
{% else %}
{% for death_report_tmg in qs %}
{% render_tmg_panel reference_obj=death_report_tmg by_user_created_only=True counter=forloop.counter next_url_name=listboard_filter_url %}
{% endfor %}
{% endif %}

</div>
</div>

Expand Down
31 changes: 30 additions & 1 deletion edc_adverse_event/templatetags/edc_adverse_event_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import TYPE_CHECKING

from django import template
from django.apps import apps as django_apps
from django.conf import settings
from django.contrib.messages import ERROR
from django.core.exceptions import ObjectDoesNotExist
Expand All @@ -17,7 +18,12 @@
from edc_model_admin.utils import add_to_messages_once
from edc_utils import escape_braces, get_utcnow

from ..constants import AE_WITHDRAWN, TMG_ROLE
from ..constants import (
AE_WITHDRAWN,
DEATH_REPORT_TMG_ACTION,
DEATH_REPORT_TMG_SECOND_ACTION,
TMG_ROLE,
)
from ..utils import get_adverse_event_app_label, get_ae_model, has_valid_tmg_perms
from ..view_utils import TmgButton

Expand Down Expand Up @@ -205,6 +211,29 @@ def ae_followup_queryset(
return None


@register.simple_tag
def death_report_tmg_action_item(subject_identifier: str = None) -> ActionItem:
try:
obj = django_apps.get_model("edc_action_item.actionitem").objects.get(
subject_identifier=subject_identifier, action_type__name=DEATH_REPORT_TMG_ACTION
)
except ObjectDoesNotExist:
obj = None
return obj


@register.simple_tag
def death_report_tmg_second_action_item(subject_identifier: str = None) -> ActionItem:
try:
obj = django_apps.get_model("edc_action_item.actionitem").objects.get(
subject_identifier=subject_identifier,
action_type__name=DEATH_REPORT_TMG_SECOND_ACTION,
)
except ObjectDoesNotExist:
obj = None
return obj


@register.inclusion_tag(
"edc_adverse_event/tmg/ae_tmg_panel.html",
takes_context=True,
Expand Down

0 comments on commit 214c9c8

Please sign in to comment.