Merge branch 'develop' into custom-rating

This commit is contained in:
Shariq Ansari 2021-12-20 18:39:17 +05:30 committed by GitHub
commit b54aa00a9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 13 deletions

View file

@ -1203,7 +1203,7 @@ def read_file(path, raise_not_found=False):
def get_attr(method_string):
"""Get python method object from its name."""
app_name = method_string.split(".")[0]
if not local.flags.in_install and app_name not in get_installed_apps():
if not local.flags.in_uninstall and not local.flags.in_install and app_name not in get_installed_apps():
throw(_("App {0} is not installed").format(app_name), AppNotInstalledError)
modulename = '.'.join(method_string.split('.')[:-1])

View file

@ -208,6 +208,7 @@ def remove_app(app_name, dry_run=False, yes=False, no_backup=False, force=False)
import click
site = frappe.local.site
app_hooks = frappe.get_hooks(app_name=app_name)
# dont allow uninstall app if not installed unless forced
if not force:
@ -233,6 +234,9 @@ def remove_app(app_name, dry_run=False, yes=False, no_backup=False, force=False)
frappe.flags.in_uninstall = True
for before_uninstall in app_hooks.before_uninstall or []:
frappe.get_attr(before_uninstall)()
modules = frappe.get_all("Module Def", filters={"app_name": app_name}, pluck="name")
drop_doctypes = _delete_modules(modules, dry_run=dry_run)
@ -243,6 +247,9 @@ def remove_app(app_name, dry_run=False, yes=False, no_backup=False, force=False)
frappe.get_single('Installed Applications').update_versions()
frappe.db.commit()
for after_uninstall in app_hooks.after_uninstall or []:
frappe.get_attr(after_uninstall)()
click.secho(f"Uninstalled App {app_name} from Site {site}", fg="green")
frappe.flags.in_uninstall = False

View file

@ -27,6 +27,6 @@ def execute():
name, script = server_script["name"], server_script["script"]
for agg in ["avg", "max", "min", "sum"]:
script = re.sub(f"frappe.db.{agg}(", f"frappe.qb.{agg}(", script)
script = re.sub(f"frappe.db.{agg}\(", f"frappe.qb.{agg}(", script)
frappe.db.update("Server Script", name, "script", script)

View file

@ -1972,12 +1972,6 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
if (!doctype) return;
frappe.provide("frappe.views.trees");
// refresh tree view
if (frappe.views.trees[doctype]) {
frappe.views.trees[doctype].tree.refresh();
return;
}
// refresh list view
const page_name = frappe.get_route_str();
const list_view = frappe.views.list_view[page_name];

View file

@ -299,7 +299,6 @@ frappe.ui.Tree = class {
.appendTo($toolbar);
$link.on('click', () => {
obj.click(node);
this.refresh();
});
});

View file

@ -242,6 +242,7 @@ frappe.views.TreeView = class TreeView {
frappe.model.rename_doc(me.doctype, node.label, function(new_name) {
node.$tree_link.find('a').text(new_name);
node.label = new_name;
me.tree.refresh();
});
},
btnClass: "hidden-xs"
@ -317,10 +318,7 @@ frappe.views.TreeView = class TreeView {
args: args,
callback: function(r) {
if(!r.exc) {
if(node.expanded) {
me.tree.toggle_node(node);
}
me.tree.load_children(node, true);
me.tree.load_children(node);
}
},
always: function() {

View file

@ -203,6 +203,12 @@ app_license = "{app_license}"
# before_install = "{app_name}.install.before_install"
# after_install = "{app_name}.install.after_install"
# Uninstallation
# ------------
# before_uninstall = "{app_name}.uninstall.before_uninstall"
# after_uninstall = "{app_name}.uninstall.after_uninstall"
# Desk Notifications
# ------------------
# See frappe.core.notifications.get_notification_config