@require_POST
@login_required
def send_test_notification(request, code):
    (channel, rw) = _get_channel_for_user(request, code)
    dummy = Check(name='TEST', status='down')
    dummy.last_ping = (timezone.now() - td(days=1))
    dummy.n_pings = 42
    if ((channel.kind == 'webhook') and (not channel.url_down)):
        if channel.url_up:
            dummy.status = 'up'
    Notification.objects.filter(channel=channel, owner=None).delete()
    error = channel.notify(dummy, is_test=True)
    if error:
        messages.warning(request, ('Could not send a test notification. %s' % error))
    else:
        messages.success(request, 'Test notification sent!')
    return redirect('hc-channels', channel.project.code)
@require_POST
@login_required
def send_test_notification(request, code):
    (channel, rw) = _get_channel_for_user(request, code)
    dummy = Check(name='TEST', status='down')
    dummy.last_ping = (timezone.now() - td(days=1))
    dummy.n_pings = 42
    if ((channel.kind == 'webhook') and (not channel.url_down)):
        if channel.url_up:
            dummy.status = 'up'
    Notification.objects.filter(channel=channel, owner=None).delete()
    error = channel.notify(dummy, is_test=True)
    if error:
        messages.warning(request, ('Could not send a test notification. %s' % error))
    else:
        messages.success(request, 'Test notification sent!')
    return redirect('hc-channels', channel.project.code)