@user_passes_test((lambda u: u.is_staff))
def add_product_endpoint(request):
    form = AddEndpointForm()
    if (request.method == 'POST'):
        form = AddEndpointForm(request.POST)
        if form.is_valid():
            endpoints = form.save()
            tags = request.POST.getlist('tags')
            t = ', '.join(tags)
            for e in endpoints:
                e.tags = t
            messages.add_message(request, messages.SUCCESS, 'Endpoint added successfully.', extra_tags='alert-success')
            return HttpResponseRedirect((reverse('endpoints') + ('?product=%s' % form.product.id)))
    add_breadcrumb(title='Add Endpoint', top_level=False, request=request)
    return render(request, 'dojo/add_endpoint.html', {'name': 'Add Endpoint', 'form': form})
@user_passes_test((lambda u: u.is_staff))
def add_product_endpoint(request):
    form = AddEndpointForm()
    if (request.method == 'POST'):
        form = AddEndpointForm(request.POST)
        if form.is_valid():
            endpoints = form.save()
            tags = request.POST.getlist('tags')
            t = ', '.join(tags)
            for e in endpoints:
                e.tags = t
            messages.add_message(request, messages.SUCCESS, 'Endpoint added successfully.', extra_tags='alert-success')
            return HttpResponseRedirect((reverse('endpoints') + ('?product=%s' % form.product.id)))
    add_breadcrumb(title='Add Endpoint', top_level=False, request=request)
    return render(request, 'dojo/add_endpoint.html', {'name': 'Add Endpoint', 'form': form})