configuration deletion added

This commit is contained in:
Yogesh Ojha
2020-07-25 20:39:16 +05:30
parent ebcd1549ce
commit 6fc0c9f501
3 changed files with 23 additions and 10 deletions
@@ -22,12 +22,7 @@ $(document).ready(function() {
function delete_api(id, name, item)
{
if (item == "engine") {
var delAPI = "delete/"+id;
}
else if (item == "wordlist"){
var delAPI = 'delete/'+id;
}
var delAPI = 'delete/'+id;
swal.queue([{
title: 'Are you sure you want to delete '+ name +'?',
text: "You won't be able to revert this!",
+4 -4
View File
@@ -40,8 +40,8 @@ urlpatterns = [
'configuration/add/',
views.add_configuration,
name='add_configuration'),
# path(
# 'configuration/delete/<int:id>',
# views.delete_configuration,
# name='delete_configuration'),
path(
'configuration/delete/<int:id>',
views.delete_configuration,
name='delete_configuration'),
]
+18
View File
@@ -147,3 +147,21 @@ def add_configuration(request):
return http.HttpResponseRedirect(reverse('configuration_list'))
context['form'] = form
return render(request, 'scanEngine/configuration/add.html', context)
def delete_configuration(request, id):
obj = get_object_or_404(Configuration, id=id)
if request.method == "POST":
obj.delete()
responseData = {'status': 'true'}
messages.add_message(
request,
messages.INFO,
'Configuration successfully deleted!')
else:
responseData = {'status': 'false'}
messages.add_message(
request,
messages.INFO,
'Oops! Configuration could not be deleted!')
return http.JsonResponse(responseData)