Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions hosts/templatetags/report_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'<img src="{alert_icon}" alt="Outdated Report" />'
return format_html(html)
alert_icon = static('img/icon-alert.gif')
return format_html('<img src="{}" alt="Outdated Report" />', alert_icon)
return ''
32 changes: 12 additions & 20 deletions repos/templatetags/repo_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<button onclick="repo_toggle_enabled'
html += f'(\'{repo_url}\', this, event)">'
if repo.enabled:
html += f'<img src="{yes_icon}" alt="Enabled" />'
else:
html += f'<img src="{no_icon}" alt="Disabled" />'
html += '</button>'
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(
'<button onclick="repo_toggle_enabled(\'{}\', this, event)"><img src="{}" alt="{}" /></button>',
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 = '<button onclick="repo_toggle_security'
html += f'(\'{repo_url}\', this, event)">'
if repo.security:
html += f'<img src="{yes_icon}" alt="Security" />'
else:
html += f'<img src="{no_icon}" alt="Non-Security" />'
html += '</button>'
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(
'<button onclick="repo_toggle_security(\'{}\', this, event)"><img src="{}" alt="{}" /></button>',
repo_url, icon, alt,
)
12 changes: 4 additions & 8 deletions util/templatetags/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,17 @@ 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'<img src="{yes_icon}" alt="{alt_yes}" />'
else:
html = f'<img src="{no_icon}" alt="{alt_no}" />'
return format_html(html)
return format_html('<img src="{}" alt="{}" />', yes_icon, alt_yes)
return format_html('<img src="{}" alt="{}" />', no_icon, alt_no)


@register.simple_tag
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'<img src="{yes_icon}" alt="{alt_yes}" />'
else:
html = f'<img src="{no_icon}" alt="{alt_no}" />'
return format_html(html)
return format_html('<img src="{}" alt="{}" />', yes_icon, alt_yes)
return format_html('<img src="{}" alt="{}" />', no_icon, alt_no)


@register.simple_tag
Expand Down
Loading