@user_passes_test((lambda u: u.is_staff))
def edit_endpoint(request, eid):
    endpoint = get_object_or_404(Endpoint, id=eid)
    if (request.method == 'POST'):
        form = EditEndpointForm(request.POST, instance=endpoint)
        if form.is_valid():
            endpoint = form.save()
            tags = request.POST.getlist('tags')
            t = ', '.join(tags)
            endpoint.tags = t
            messages.add_message(request, messages.SUCCESS, 'Endpoint updated successfully.', extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_endpoint', args=(endpoint.id,)))
    add_breadcrumb(parent=endpoint, title='Edit', top_level=False, request=request)
    form = EditEndpointForm(instance=endpoint)
    form.initial['tags'] = [tag.name for tag in endpoint.tags]
    product_tab = Product_Tab(endpoint.product.id, 'Endpoint', tab='endpoints')
    return render(request, 'dojo/edit_endpoint.html', {'endpoint': endpoint, 'product_tab': product_tab, 'form': form})
@user_passes_test((lambda u: u.is_staff))
def edit_endpoint(request, eid):
    endpoint = get_object_or_404(Endpoint, id=eid)
    if (request.method == 'POST'):
        form = EditEndpointForm(request.POST, instance=endpoint)
        if form.is_valid():
            endpoint = form.save()
            tags = request.POST.getlist('tags')
            t = ', '.join(tags)
            endpoint.tags = t
            messages.add_message(request, messages.SUCCESS, 'Endpoint updated successfully.', extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_endpoint', args=(endpoint.id,)))
    add_breadcrumb(parent=endpoint, title='Edit', top_level=False, request=request)
    form = EditEndpointForm(instance=endpoint)
    form.initial['tags'] = [tag.name for tag in endpoint.tags]
    product_tab = Product_Tab(endpoint.product.id, 'Endpoint', tab='endpoints')
    return render(request, 'dojo/edit_endpoint.html', {'endpoint': endpoint, 'product_tab': product_tab, 'form': form})