forked from GithubBackups/healthchecks
DRY: adding "now_isoformat" template tag
This commit is contained in:
parent
92542fa818
commit
c596f485a5
@ -4,6 +4,7 @@ from django import template
|
||||
from django.conf import settings
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.timezone import now
|
||||
|
||||
from hc.lib.date import format_duration, format_approx_duration, format_hms
|
||||
|
||||
@ -151,3 +152,8 @@ def fix_asterisks(s):
|
||||
@register.filter
|
||||
def format_headers(headers):
|
||||
return "\n".join("%s: %s" % (k, v) for k, v in headers.items())
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def now_isoformat():
|
||||
return now().replace(microsecond=0).isoformat()
|
||||
|
@ -179,7 +179,6 @@ def my_checks(request, code):
|
||||
"checks": checks,
|
||||
"channels": channels,
|
||||
"num_down": num_down,
|
||||
"now": timezone.now(),
|
||||
"tags": pairs,
|
||||
"ping_endpoint": settings.PING_ENDPOINT,
|
||||
"timezones": pytz.all_timezones,
|
||||
@ -860,7 +859,6 @@ def add_webhook(request, code):
|
||||
"page": "channels",
|
||||
"project": project,
|
||||
"form": form,
|
||||
"now": timezone.now().replace(microsecond=0).isoformat(),
|
||||
}
|
||||
return render(request, "integrations/webhook_form.html", ctx)
|
||||
|
||||
@ -896,7 +894,6 @@ def edit_webhook(request, code):
|
||||
"project": channel.project,
|
||||
"channel": channel,
|
||||
"form": form,
|
||||
"now": timezone.now().replace(microsecond=0).isoformat(),
|
||||
}
|
||||
return render(request, "integrations/webhook_form.html", ctx)
|
||||
|
||||
@ -921,7 +918,6 @@ def add_shell(request, code):
|
||||
"page": "channels",
|
||||
"project": project,
|
||||
"form": form,
|
||||
"now": timezone.now().replace(microsecond=0).isoformat(),
|
||||
}
|
||||
return render(request, "integrations/add_shell.html", ctx)
|
||||
|
||||
|
@ -94,7 +94,7 @@
|
||||
<th><code>$NOW</code></th>
|
||||
<td>
|
||||
Current UTC time in ISO8601 format.<br />
|
||||
Example: "{{ now }}"
|
||||
Example: "{% now_isoformat %}"
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -198,7 +198,7 @@
|
||||
<th><code>$NOW</code></th>
|
||||
<td>
|
||||
Current UTC time in ISO8601 format.<br />
|
||||
Example: "{{ now }}"
|
||||
Example: "{% now_isoformat %}"
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user