def mass_delete(cls, pathname_list, user, delete_pkgs=False): '''Deletes pkginfo files from a list and optionally deletes the associated installer items (pkgs)''' errors = [] catalog_items = [] if delete_pkgs: # cache the catalog_items once; we don't want to incur the # overhead of reading the 'all' catalog multiple times catalog_items = Catalog.detail('all') for pathname in pathname_list: delete_this_pkg = False if delete_pkgs: ref_count, pkg_path = pkg_ref_count(pathname, catalog_items) if ref_count == 1: # OK to delete the pkg if there is only one pkginfo # file that refers to it delete_this_pkg = True try: cls.delete('pkgsinfo', pathname, user) except FileDeleteError, err: errors.append('Error %s when removing %s' % (err, pathname)) else: if delete_this_pkg: try: MunkiFile.delete('pkgs', pkg_path, user) except FileDeleteError, err: errors.append('Error %s when removing %s' % (err, pkg_path))
if not request.user.has_perm("pkgsinfo.delete_pkginfofile"): raise PermissionDenied if not filepath: return HttpResponse( json.dumps( { "result": "failed", "exception_type": "MassDeleteNotSupported", "detail": "Deleting all items is not supported", } ), content_type="application/json", status=403, ) try: MunkiFile.delete(kind, filepath, request.user) except FileDoesNotExistError, err: return HttpResponse( json.dumps({"result": "failed", "exception_type": str(type(err)), "detail": str(err)}), content_type="application/json", status=404, ) except FileDeleteError, err: return HttpResponse( json.dumps({"result": "failed", "exception_type": str(type(err)), "detail": str(err)}), content_type="application/json", status=403, ) except FileError, err: return HttpResponse( json.dumps({"result": "failed", "exception_type": str(type(err)), "detail": str(err)}),
response['Allow'] = 'GET, POST, PUT, DELETE' return response if request.method == 'DELETE': LOGGER.debug("Got API DELETE request for %s", kind) if not request.user.has_perm('pkgsinfo.delete_pkginfofile'): raise PermissionDenied if not filepath: return HttpResponse( json.dumps({'result': 'failed', 'exception_type': 'MassDeleteNotSupported', 'detail': 'Deleting all items is not supported'} ), content_type='application/json', status=403) try: MunkiFile.delete(kind, filepath, request.user) except FileDoesNotExistError, err: return HttpResponse( json.dumps({'result': 'failed', 'exception_type': str(type(err)), 'detail': str(err)}), content_type='application/json', status=404) except FileDeleteError, err: return HttpResponse( json.dumps({'result': 'failed', 'exception_type': str(type(err)), 'detail': str(err)}), content_type='application/json', status=403) except FileError, err: return HttpResponse( json.dumps({'result': 'failed',