@login_required
def add_pd(request, code):
    project = _get_rw_project_for_user(request, code)
    if (request.method == 'POST'):
        form = forms.AddPdForm(request.POST)
        if form.is_valid():
            channel = Channel(project=project, kind='pd')
            channel.value = form.cleaned_data['value']
            channel.save()
            channel.assign_all_checks()
            return redirect('hc-channels', project.code)
    else:
        form = forms.AddPdForm()
    ctx = {'page': 'channels', 'form': form}
    return render(request, 'integrations/add_pd.html', ctx)
@login_required
def add_pd(request, code):
    project = _get_rw_project_for_user(request, code)
    if (request.method == 'POST'):
        form = forms.AddPdForm(request.POST)
        if form.is_valid():
            channel = Channel(project=project, kind='pd')
            channel.value = form.cleaned_data['value']
            channel.save()
            channel.assign_all_checks()
            return redirect('hc-channels', project.code)
    else:
        form = forms.AddPdForm()
    ctx = {'page': 'channels', 'form': form}
    return render(request, 'integrations/add_pd.html', ctx)