@require_POST
@csrf_protect
def generic_delete(request, what, obj_name=None):
 if (not test_user_authenticated(request)):
  return login(request, next=('/cobbler_web/%s/delete/%s' % (what, obj_name)), expired=True)
 if (obj_name is None):
  return error_page(request, ('You must specify a %s to delete' % what))
 if (not remote.has_item(what, obj_name)):
  return error_page(request, ('Unknown %s specified' % what))
 elif (not remote.check_access_no_fail(request.session['token'], ('remove_%s' % what), obj_name)):
  return error_page(request, ('You do not have permission to delete this %s' % what))
 else:
  recursive = simplejson.loads(request.POST.get('recursive', 'false'))
  try:
   remote.xapi_object_edit(what, obj_name, 'remove', {'name': obj_name, 'recursive': recursive}, request.session['token'])
  except Exception as e:
   return error_page(request, str(e))
  return HttpResponseRedirect(('/cobbler_web/%s/list' % what))

@ require_POST @ csrf_protect def generic_delete ( request , what , obj_name = None ) : if ( not test_user_authenticated ( request ) ) : return login ( request , next = ( '/cobbler_web/%s/delete/%s' % ( what , obj_name ) ) , expired = True ) if ( obj_name is None ) : return error_page ( request , ( 'You must specify a %s to delete' % what ) ) if ( not remote . has_item ( what , obj_name ) ) : return error_page ( request , ( 'Unknown %s specified' % what ) ) elif ( not remote . check_access_no_fail ( request . session [ 'token' ] , ( 'remove_%s' % what ) , obj_name ) ) : return error_page ( request , ( 'You do not have permission to delete this %s' % what ) ) else : recursive = simplejson . loads ( request . POST . get ( 'recursive' , 'false' ) ) try : remote . xapi_object_edit ( what , obj_name , 'remove' , { 'name' : obj_name , 'recursive' : recursive } , request . session [ 'token' ] ) except Exception as e : return error_page ( request , str ( e ) ) return HttpResponseRedirect ( ( '/cobbler_web/%s/list' % what ) )
deletes an object .