def done(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_move = request.POST.getlist('final_items_to_move[]') confirm_move = request.POST.get('confirm_move') confirm_add = request.POST.get('confirm_add') confirm_remove = request.POST.get('confirm_remove') new_dest_catalog = request.POST.get('new_dest_catalog') if new_dest_catalog: new_dest_catalog = new_dest_catalog.lower() tuple(final_items_to_move) for n,pkg in enumerate(final_items_to_move): pkg = pkg.split('___') final_items_to_move[n] = pkg if confirm_remove: for pkg_name, pkg_version, pkg_orig in final_items_to_move: if pkg_orig != 'no-catalog': Packages.remove(pkg_name, pkg_version, pkg_orig, request.user) elif confirm_add: for pkg_name, pkg_version, pkg_orig, pkg_catalog in final_items_to_move: if pkg_orig == 'no-catalog': if pkg_catalog == 'set-new' and new_dest_catalog: Packages.move(pkg_name, pkg_version, new_dest_catalog, request.user) elif pkg_catalog != 'set-new': Packages.move(pkg_name, pkg_version, pkg_catalog, request.user) else: if pkg_catalog == 'set-new' and new_dest_catalog: Packages.add(pkg_name, pkg_version, pkg_orig, new_dest_catalog, request.user) elif pkg_catalog != 'set-new': Packages.add(pkg_name, pkg_version, pkg_orig, pkg_catalog, request.user) else: for pkg_name, pkg_version, pkg_catalog in final_items_to_move: if new_dest_catalog: # pkg_catalog = new_dest_catalog Packages.move(pkg_name, pkg_version, new_dest_catalog, request.user) elif pkg_catalog != 'set-new': Packages.move(pkg_name, pkg_version, pkg_catalog, request.user) Packages.makecatalogs(request.user) c = RequestContext(request, {'user': request.user, 'final_items_to_move': final_items_to_move, 'confirm_move': confirm_move, 'confirm_add': confirm_add, 'confirm_remove': confirm_remove, # '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, 'done': 'Done', 'page': 'pkgs'}) return render_to_response('pkgs/done.html', c) else: return HttpResponse("No form submitted.\n")
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 done(request): if request.method == 'POST': # If the form has been submitted... final_items_to_move = request.POST.getlist('final_items_to_move[]') confirm_move = request.POST.get('confirm_move') confirm_add = request.POST.get('confirm_add') confirm_remove = request.POST.get('confirm_remove') new_dest_catalog = request.POST.get('new_dest_catalog') if new_dest_catalog: new_dest_catalog = new_dest_catalog.lower() tuple(final_items_to_move) for n,pkg in enumerate(final_items_to_move): pkg = pkg.split('___') final_items_to_move[n] = pkg if confirm_remove: for pkg_name, pkg_version, pkg_orig in final_items_to_move: if pkg_orig != 'no-catalog': Packages.remove(pkg_name, pkg_version, pkg_orig) elif confirm_add: for pkg_name, pkg_version, pkg_orig, pkg_catalog in final_items_to_move: if pkg_orig == 'no-catalog': if pkg_catalog == 'set-new' and new_dest_catalog: Packages.move(pkg_name, pkg_version, new_dest_catalog) elif pkg_catalog != 'set-new': Packages.move(pkg_name, pkg_version, pkg_catalog) else: if pkg_catalog == 'set-new' and new_dest_catalog: Packages.add(pkg_name, pkg_version, pkg_orig, new_dest_catalog) elif pkg_catalog != 'set-new': Packages.add(pkg_name, pkg_version, pkg_orig, pkg_catalog) else: for pkg_name, pkg_version, pkg_catalog in final_items_to_move: if new_dest_catalog: pkg_catalog = new_dest_catalog elif pkg_catalog != 'set-new': Packages.move(pkg_name, pkg_version, pkg_catalog) Packages.makecatalogs() context = {'user': request.user, 'final_items_to_move': final_items_to_move, 'confirm_move': confirm_move, 'confirm_add': confirm_add, 'confirm_remove': confirm_remove, 'done': 'Done', 'page': 'pkgs'} return render_to_response('pkgs/done.html', context) 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")