forked from GithubBackups/healthchecks
Fetch ping details using HTTP GET, not HTTP POST.
This commit is contained in:
parent
97b3b52df5
commit
7e56eb883e
@ -11,12 +11,12 @@ class LastPingTestCase(BaseTestCase):
|
|||||||
Ping.objects.create(owner=check, body="this is body")
|
Ping.objects.create(owner=check, body="this is body")
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
r = self.client.post("/checks/%s/last_ping/" % check.code)
|
r = self.client.get("/checks/%s/last_ping/" % check.code)
|
||||||
self.assertContains(r, "this is body", status_code=200)
|
self.assertContains(r, "this is body", status_code=200)
|
||||||
|
|
||||||
def test_it_requires_user(self):
|
def test_it_requires_user(self):
|
||||||
check = Check.objects.create()
|
check = Check.objects.create()
|
||||||
r = self.client.post("/checks/%s/last_ping/" % check.code)
|
r = self.client.get("/checks/%s/last_ping/" % check.code)
|
||||||
self.assertEqual(r.status_code, 403)
|
self.assertEqual(r.status_code, 403)
|
||||||
|
|
||||||
def test_it_accepts_n(self):
|
def test_it_accepts_n(self):
|
||||||
@ -29,8 +29,8 @@ class LastPingTestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
|
|
||||||
r = self.client.post("/checks/%s/pings/1/" % check.code)
|
r = self.client.get("/checks/%s/pings/1/" % check.code)
|
||||||
self.assertContains(r, "foo-123", status_code=200)
|
self.assertContains(r, "foo-123", status_code=200)
|
||||||
|
|
||||||
r = self.client.post("/checks/%s/pings/2/" % check.code)
|
r = self.client.get("/checks/%s/pings/2/" % check.code)
|
||||||
self.assertContains(r, "bar-456", status_code=200)
|
self.assertContains(r, "bar-456", status_code=200)
|
||||||
|
@ -275,7 +275,6 @@ def cron_preview(request):
|
|||||||
return render(request, "front/cron_preview.html", ctx)
|
return render(request, "front/cron_preview.html", ctx)
|
||||||
|
|
||||||
|
|
||||||
@require_POST
|
|
||||||
def ping_details(request, code, n=None):
|
def ping_details(request, code, n=None):
|
||||||
if not request.user.is_authenticated:
|
if not request.user.is_authenticated:
|
||||||
return HttpResponseForbidden()
|
return HttpResponseForbidden()
|
||||||
|
@ -44,7 +44,6 @@ $(function () {
|
|||||||
|
|
||||||
$(".last-ping").on("click", function() {
|
$(".last-ping").on("click", function() {
|
||||||
if (this.innerText == "Never") {
|
if (this.innerText == "Never") {
|
||||||
showUsage(this);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,14 +52,8 @@ $(function () {
|
|||||||
|
|
||||||
var code = $(this).closest("tr.checks-row").attr("id");
|
var code = $(this).closest("tr.checks-row").attr("id");
|
||||||
var lastPingUrl = "/checks/" + code + "/last_ping/";
|
var lastPingUrl = "/checks/" + code + "/last_ping/";
|
||||||
var token = $('input[name=csrfmiddlewaretoken]').val();
|
$.get(lastPingUrl, function(data) {
|
||||||
$.ajax({
|
$("#ping-details-body" ).html(data);
|
||||||
url: lastPingUrl,
|
|
||||||
type: "post",
|
|
||||||
headers: {"X-CSRFToken": token},
|
|
||||||
success: function(data) {
|
|
||||||
$("#ping-details-body" ).html(data);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var logUrl = "/checks/" + code + "/log/";
|
var logUrl = "/checks/" + code + "/log/";
|
||||||
|
@ -88,15 +88,10 @@ $(function () {
|
|||||||
$("#ping-details-body").text("Updating...");
|
$("#ping-details-body").text("Updating...");
|
||||||
$('#ping-details-modal').modal("show");
|
$('#ping-details-modal').modal("show");
|
||||||
|
|
||||||
var token = $('input[name=csrfmiddlewaretoken]').val();
|
$.get(this.dataset.url, function(data) {
|
||||||
$.ajax({
|
$("#ping-details-body").html(data);
|
||||||
url: this.dataset.url,
|
|
||||||
type: "post",
|
|
||||||
headers: {"X-CSRFToken": token},
|
|
||||||
success: function(data) {
|
|
||||||
$("#ping-details-body" ).html(data);
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -3,14 +3,8 @@ $(function () {
|
|||||||
$("#ping-details-body").text("Updating...");
|
$("#ping-details-body").text("Updating...");
|
||||||
$('#ping-details-modal').modal("show");
|
$('#ping-details-modal').modal("show");
|
||||||
|
|
||||||
var token = $('input[name=csrfmiddlewaretoken]').val();
|
$.get(this.dataset.url, function(data) {
|
||||||
$.ajax({
|
$("#ping-details-body" ).html(data);
|
||||||
url: this.dataset.url,
|
|
||||||
type: "post",
|
|
||||||
headers: {"X-CSRFToken": token},
|
|
||||||
success: function(data) {
|
|
||||||
$("#ping-details-body" ).html(data);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -26,7 +20,6 @@ $(function () {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$("#format-switcher").click(function(ev) {
|
$("#format-switcher").click(function(ev) {
|
||||||
var format = ev.target.getAttribute("data-format");
|
var format = ev.target.getAttribute("data-format");
|
||||||
switchDateFormat(format);
|
switchDateFormat(format);
|
||||||
|
@ -144,9 +144,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form>
|
|
||||||
{% csrf_token %}
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user