def all_endpoints(request):
    endpoints = Endpoint.objects.all()
    show_uri = get_system_setting('display_endpoint_uri')
    if request.user.is_staff:
        pass
    else:
        products = Product.objects.filter(authorized_users__in=[request.user])
        if products.exists():
            endpoints = endpoints.filter(product__in=products.all())
        else:
            raise PermissionDenied
    product = None
    if ('product' in request.GET):
        p = request.GET.getlist('product', [])
        if (len(p) == 1):
            product = get_object_or_404(Product, id=p[0])
    if show_uri:
        endpoints = EndpointFilter(request.GET, queryset=endpoints, user=request.user)
        paged_endpoints = get_page_items(request, endpoints.qs, 25)
    else:
        ids = get_endpoint_ids(EndpointFilter(request.GET, queryset=endpoints, user=request.user).qs)
        endpoints = EndpointFilter(request.GET, queryset=endpoints.filter(id__in=ids), user=request.user)
        paged_endpoints = get_page_items(request, endpoints.qs, 25)
    add_breadcrumb(title='All Endpoints', top_level=(not len(request.GET)), request=request)
    product_tab = None
    view_name = 'All Endpoints'
    if product:
        view_name = 'Endpoints'
        product_tab = Product_Tab(product.id, 'Endpoints', tab='endpoints')
    return render(request, 'dojo/endpoints.html', {'product_tab': product_tab, 'endpoints': paged_endpoints, 'filtered': endpoints, 'name': view_name, 'show_uri': show_uri})
def all_endpoints(request):
    endpoints = Endpoint.objects.all()
    show_uri = get_system_setting('display_endpoint_uri')
    if request.user.is_staff:
        pass
    else:
        products = Product.objects.filter(authorized_users__in=[request.user])
        if products.exists():
            endpoints = endpoints.filter(product__in=products.all())
        else:
            raise PermissionDenied
    product = None
    if ('product' in request.GET):
        p = request.GET.getlist('product', [])
        if (len(p) == 1):
            product = get_object_or_404(Product, id=p[0])
    if show_uri:
        endpoints = EndpointFilter(request.GET, queryset=endpoints, user=request.user)
        paged_endpoints = get_page_items(request, endpoints.qs, 25)
    else:
        ids = get_endpoint_ids(EndpointFilter(request.GET, queryset=endpoints, user=request.user).qs)
        endpoints = EndpointFilter(request.GET, queryset=endpoints.filter(id__in=ids), user=request.user)
        paged_endpoints = get_page_items(request, endpoints.qs, 25)
    add_breadcrumb(title='All Endpoints', top_level=(not len(request.GET)), request=request)
    product_tab = None
    view_name = 'All Endpoints'
    if product:
        view_name = 'Endpoints'
        product_tab = Product_Tab(product.id, 'Endpoints', tab='endpoints')
    return render(request, 'dojo/endpoints.html', {'product_tab': product_tab, 'endpoints': paged_endpoints, 'filtered': endpoints, 'name': view_name, 'show_uri': show_uri})