@require_POST
@login_required
def copy(request, code):
    check = _get_rw_check_for_user(request, code)
    if (check.project.num_checks_available() <= 0):
        return HttpResponseBadRequest()
    new_name = (check.name + ' (copy)')
    if (len(new_name) > 100):
        new_name = (check.name[:90] + '... (copy)')
    copied = Check(project=check.project)
    copied.name = new_name
    (copied.desc, copied.tags) = (check.desc, check.tags)
    (copied.subject, copied.subject_fail) = (check.subject, check.subject_fail)
    copied.methods = check.methods
    copied.manual_resume = check.manual_resume
    copied.kind = check.kind
    (copied.timeout, copied.grace) = (check.timeout, check.grace)
    (copied.schedule, copied.tz) = (check.schedule, check.tz)
    copied.save()
    copied.channel_set.add(*check.channel_set.all())
    url = reverse('hc-details', args=[copied.code])
    return redirect((url + '?copied'))
@require_POST
@login_required
def copy(request, code):
    check = _get_rw_check_for_user(request, code)
    if (check.project.num_checks_available() <= 0):
        return HttpResponseBadRequest()
    new_name = (check.name + ' (copy)')
    if (len(new_name) > 100):
        new_name = (check.name[:90] + '... (copy)')
    copied = Check(project=check.project)
    copied.name = new_name
    (copied.desc, copied.tags) = (check.desc, check.tags)
    (copied.subject, copied.subject_fail) = (check.subject, check.subject_fail)
    copied.methods = check.methods
    copied.manual_resume = check.manual_resume
    copied.kind = check.kind
    (copied.timeout, copied.grace) = (check.timeout, check.grace)
    (copied.schedule, copied.tz) = (check.schedule, check.tz)
    copied.save()
    copied.channel_set.add(*check.channel_set.all())
    url = reverse('hc-details', args=[copied.code])
    return redirect((url + '?copied'))