def delete_endpoint(request, eid): endpoint = get_object_or_404(Endpoint, pk=eid) product = endpoint.product form = DeleteEndpointForm(instance=endpoint) if request.method == 'POST': if 'id' in request.POST and str(endpoint.id) == request.POST['id']: form = DeleteEndpointForm(request.POST, instance=endpoint) if form.is_valid(): product = endpoint.product endpoint.delete() messages.add_message(request, messages.SUCCESS, 'Endpoint and relationships removed.', extra_tags='alert-success') create_notification(event='other', title='Deletion of %s' % endpoint, product=product, description='The endpoint "%s" was deleted by %s' % (endpoint, request.user), url=request.build_absolute_uri(reverse('endpoint')), icon="exclamation-triangle") return HttpResponseRedirect(reverse('view_product', args=(product.id,))) collector = NestedObjects(using=DEFAULT_DB_ALIAS) collector.collect([endpoint]) rels = collector.nested() product_tab = Product_Tab(endpoint.product.id, "Delete Endpoint", tab="endpoints") return render(request, 'dojo/delete_endpoint.html', {'endpoint': endpoint, 'product_tab': product_tab, 'form': form, 'rels': rels, })
def delete_endpoint(request, eid): endpoint = get_object_or_404(Endpoint, pk=eid) product = endpoint.product form = DeleteEndpointForm(instance=endpoint) from django.contrib.admin.util import NestedObjects from django.db import DEFAULT_DB_ALIAS collector = NestedObjects(using=DEFAULT_DB_ALIAS) collector.collect([endpoint]) rels = collector.nested() if request.method == 'POST': if 'id' in request.POST and str(endpoint.id) == request.POST['id']: form = DeleteEndpointForm(request.POST, instance=endpoint) if form.is_valid(): endpoint.delete() messages.add_message(request, messages.SUCCESS, 'Endpoint and relationships removed.', extra_tags='alert-success') return HttpResponseRedirect( reverse('view_product', args=(product.id, ))) add_breadcrumb(parent=endpoint, title="Delete", top_level=False, request=request) return render(request, 'dojo/delete_endpoint.html', { 'endpoint': endpoint, 'form': form, 'rels': rels, })
def delete_endpoint(request, eid): endpoint = get_object_or_404(Endpoint, pk=eid) product = endpoint.product form = DeleteEndpointForm(instance=endpoint) if request.method == 'POST': if 'id' in request.POST and str(endpoint.id) == request.POST['id']: form = DeleteEndpointForm(request.POST, instance=endpoint) if form.is_valid(): del endpoint.tags endpoint.delete() messages.add_message(request, messages.SUCCESS, 'Endpoint and relationships removed.', extra_tags='alert-success') return HttpResponseRedirect(reverse('view_endpoint', args=(product.id,))) collector = NestedObjects(using=DEFAULT_DB_ALIAS) collector.collect([endpoint]) rels = collector.nested() product_tab = Product_Tab(endpoint.product.id, "Delete Endpoint", tab="endpoints") return render(request, 'dojo/delete_endpoint.html', {'endpoint': endpoint, 'product_tab': product_tab, 'form': form, 'rels': rels, })
def delete_endpoint(request, eid): endpoint = get_object_or_404(Endpoint, pk=eid) product = endpoint.product form = DeleteEndpointForm(instance=endpoint) from django.contrib.admin.util import NestedObjects from django.db import DEFAULT_DB_ALIAS collector = NestedObjects(using=DEFAULT_DB_ALIAS) collector.collect([endpoint]) rels = collector.nested() if request.method == 'POST': if 'id' in request.POST and str(endpoint.id) == request.POST['id']: form = DeleteEndpointForm(request.POST, instance=endpoint) if form.is_valid(): endpoint.delete() messages.add_message(request, messages.SUCCESS, 'Endpoint and relationships removed.', extra_tags='alert-success') return HttpResponseRedirect(reverse('view_product', args=(product.id,))) add_breadcrumb(parent=endpoint, title="Delete", top_level=False, request=request) return render(request, 'dojo/delete_endpoint.html', {'endpoint': endpoint, 'form': form, 'rels': rels, })
def delete_endpoint(request, eid): endpoint = get_object_or_404(Endpoint, pk=eid) product = endpoint.product form = DeleteEndpointForm(instance=endpoint) if request.method == 'POST': if 'id' in request.POST and str(endpoint.id) == request.POST['id']: form = DeleteEndpointForm(request.POST, instance=endpoint) if form.is_valid(): del endpoint.tags endpoint.delete() messages.add_message(request, messages.SUCCESS, 'Endpoint and relationships removed.', extra_tags='alert-success') return HttpResponseRedirect( reverse('view_endpoint', args=(product.id, ))) collector = NestedObjects(using=DEFAULT_DB_ALIAS) collector.collect([endpoint]) rels = collector.nested() product_tab = Product_Tab(endpoint.product.id, "Delete Endpoint", tab="endpoints") return render( request, 'dojo/delete_endpoint.html', { 'endpoint': endpoint, 'product_tab': product_tab, 'form': form, 'rels': rels, })