def deleted(request): # can_view_pkgs = request.user.has_perm('pkgs.can_view_pkgs') # can_view_manifests = request.user.has_perm('manifests.can_view_manifests') # can_view_catalogs = request.user.has_perm('catalogs.can_view_catalogs') # change_pkgs = request.user.has_perm('pkgs.change_pkgs') # delete_pkgs = request.user.has_perm('pkgs.delete_pkgs') if request.method == 'POST': # If the form has been submitted... final_items_to_delete = request.POST.getlist('final_items_to_delete[]') confirm_delete = request.POST.getlist('confirm_delete') confirm_delete_pkgs = request.POST.getlist('confirm_delete_pkgs') tuple(final_items_to_delete) deleted_packages = [] if confirm_delete: for n,pkg in enumerate(final_items_to_delete): pkg = pkg.split('___') final_items_to_delete[n] = pkg for pkg_name, pkg_version, pkg_location in final_items_to_delete: try: Packages.delete_pkgs(pkg_name, pkg_version, request.user) deleted = 'deleted' except OSError as e: logger.info("The error was %s" % e) deleted = None Packages.makecatalogs(request.user) else: for pkg_location in final_items_to_delete: try: Packages.delete_orphaned_pkg(pkg_location, request.user) deleted = 'deleted' except OSError as e: logger.info("The error was %s" % e) deleted = None if not GIT_IGNORE_PKGS: Packages.makecatalogs(request.user) deleted_packages.append(pkg_location) c = RequestContext(request, {'user': request.user, 'final_items_to_delete': final_items_to_delete, 'deleted_packages': deleted_packages, 'deleted': deleted, # 'can_view_pkgs': can_view_pkgs, # 'can_view_manifests': can_view_manifests, # 'can_view_catalogs': can_view_catalogs, # 'change_pkgs': change_pkgs, # 'delete_pkgs': delete_pkgs, 'page': 'pkgs'}) return render_to_response('pkgs/deleted.html', c) else: return HttpResponse("No form submitted.\n")
def deleted(request): if request.method == 'POST': # If the form has been submitted... final_items_to_delete = request.POST.getlist('final_items_to_delete[]') tuple(final_items_to_delete) deleted_packages = [] for n,pkg in enumerate(final_items_to_delete): pkg = pkg.split('___') final_items_to_delete[n] = pkg for pkg_name, pkg_version, pkg_location in final_items_to_delete: Packages.delete_pkgs(pkg_name, pkg_version) deleted_packages.append(pkg_location) Packages.makecatalogs() context = {'user': request.user, 'final_items_to_delete': final_items_to_delete, 'deleted_packages': deleted_packages, 'deleted': 'Deleted', 'page': 'pkgs'} return render_to_response('pkgs/deleted.html', context) else: return HttpResponse("No form submitted.\n")