def disable(request, clientid): """ Disable the given alert. A disabled alert can never be enabled. """ if request.method == "POST": form = DisableAlertForm(request.POST) alert = get_object_or_404(Alert, pk=form.data['id']) alerts.disable_alert(alert.removeurl) alert.disabled = True alert.save() return HttpResponse() else: raise Http404
def test_disable_alert_bad_url(): """ Should raise errors if the url doesn't start with "/alerts". """ alerts.disable_alert("")
def test_disable_alert_google_down(): """ The url provided returns a 404 which should raise a 404. """ alerts.disable_alert("/alerts/disable/bad")