Skip to content

Commit

Permalink
format_html, mark_safe, translations
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 22, 2025
1 parent e8462c9 commit 97f0a5e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions edc_metadata/admin/modeladmin_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django_audit_fields import ModelAdminAuditFieldsMixin, audit_fieldset_tuple
from django_revision.modeladmin_mixin import ModelAdminRevisionMixin
from edc_appointment.utils import get_appointment_model_cls
Expand Down Expand Up @@ -171,7 +172,7 @@ def get_subject_dashboard_url(self, obj=None) -> str | None:
def dashboard(self, obj=None, label=None) -> str:
url = self.get_subject_dashboard_url(obj=obj)
context = dict(title="Go to subject's dashboard", url=url, label=label)
return render_to_string("dashboard_button.html", context=context)
return render_to_string("edc_subject_dashboard/dashboard_button.html", context=context)

@staticmethod
def seq(obj=None):
Expand All @@ -180,9 +181,15 @@ def seq(obj=None):
@staticmethod
def status(obj=None):
if obj.entry_status == REQUIRED:
return format_html('<font color="orange">New</font>')
return format_html(
"{html}",
html=mark_safe('<font color="orange">New</font>'), # nosec B703, B308
)
if obj.entry_status == KEYED:
return format_html('<font color="green">Keyed</font>')
return format_html(
"{html}",
html=mark_safe('<font color="green">Keyed</font>'), # nosec B703, B308
)
return obj.get_entry_status_display()

def get_view_on_site_url(self, obj=None):
Expand Down

0 comments on commit 97f0a5e

Please sign in to comment.