diff --git a/hosts/templatetags/report_alert.py b/hosts/templatetags/report_alert.py index a28c50588..a763647cd 100644 --- a/hosts/templatetags/report_alert.py +++ b/hosts/templatetags/report_alert.py @@ -28,13 +28,12 @@ @register.simple_tag def report_alert(lastreport): - html = '' - alert_icon = static('img/icon-alert.gif') days = get_setting_of_type( setting_name='DAYS_WITHOUT_REPORT', setting_type=int, default=14, ) if lastreport < (timezone.now() - timedelta(days=days)): - html = f'Outdated Report' - return format_html(html) + alert_icon = static('img/icon-alert.gif') + return format_html('Outdated Report', alert_icon) + return '' diff --git a/repos/templatetags/repo_buttons.py b/repos/templatetags/repo_buttons.py index 3689c8b7c..2ba3950ee 100644 --- a/repos/templatetags/repo_buttons.py +++ b/repos/templatetags/repo_buttons.py @@ -26,29 +26,21 @@ def yes_no_button_repo_en(repo): repo_url = repo.get_absolute_url() - yes_icon = static('img/icon-yes.gif') - no_icon = static('img/icon-no.gif') - html = '' - return format_html(html) + icon = static('img/icon-yes.gif') if repo.enabled else static('img/icon-no.gif') + alt = 'Enabled' if repo.enabled else 'Disabled' + return format_html( + '', + repo_url, icon, alt, + ) @register.simple_tag def yes_no_button_repo_sec(repo): repo_url = repo.get_absolute_url() - yes_icon = static('img/icon-yes.gif') - no_icon = static('img/icon-no.gif') - html = '' - return format_html(html) + icon = static('img/icon-yes.gif') if repo.security else static('img/icon-no.gif') + alt = 'Security' if repo.security else 'Non-Security' + return format_html( + '', + repo_url, icon, alt, + ) diff --git a/util/templatetags/common.py b/util/templatetags/common.py index 6737c4386..ffb795567 100644 --- a/util/templatetags/common.py +++ b/util/templatetags/common.py @@ -45,10 +45,8 @@ def yes_no_img(boolean, alt_yes='Active', alt_no='Not Active'): yes_icon = static('img/icon-yes.gif') no_icon = static('img/icon-no.gif') if boolean: - html = f'{alt_yes}' - else: - html = f'{alt_no}' - return format_html(html) + return format_html('{}', yes_icon, alt_yes) + return format_html('{}', no_icon, alt_no) @register.simple_tag @@ -56,10 +54,8 @@ def no_yes_img(boolean, alt_yes='Not Required', alt_no='Required'): yes_icon = static('img/icon-yes.gif') no_icon = static('img/icon-no.gif') if not boolean: - html = f'{alt_yes}' - else: - html = f'{alt_no}' - return format_html(html) + return format_html('{}', yes_icon, alt_yes) + return format_html('{}', no_icon, alt_no) @register.simple_tag