Skip to content

Commit

Permalink
Merge pull request #26358 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
ankush committed May 7, 2024
2 parents 6b9472e + 75b2a86 commit 0a2aaec
Show file tree
Hide file tree
Showing 68 changed files with 1,472 additions and 181 deletions.
11 changes: 9 additions & 2 deletions cypress/integration/control_link.js
Expand Up @@ -27,7 +27,7 @@ context("Control Link", () => {
}

function get_dialog_with_gender_link() {
return cy.dialog({
let dialog = cy.dialog({
title: "Link",
fields: [
{
Expand All @@ -38,6 +38,8 @@ context("Control Link", () => {
},
],
});
cy.wait(500);
return dialog;
}

it("should set the valid value", () => {
Expand All @@ -62,6 +64,7 @@ context("Control Link", () => {
cy.wait("@search_link");
cy.get("@input").type("todo for link", { delay: 200 });
cy.wait("@search_link");
cy.wait(500);
cy.get(".frappe-control[data-fieldname=link]").findByRole("listbox").should("be.visible");
cy.get(".frappe-control[data-fieldname=link] input").type("{enter}", { delay: 100 });
cy.get(".frappe-control[data-fieldname=link] input").blur();
Expand All @@ -82,6 +85,7 @@ context("Control Link", () => {
.type("invalid value", { delay: 100 })
.blur();
cy.wait("@validate_link");
cy.wait(500);
cy.get(".frappe-control[data-fieldname=link] input").should("have.value", "");
});

Expand All @@ -92,6 +96,7 @@ context("Control Link", () => {

cy.get(".frappe-control[data-fieldname=link] input").type(" ", { delay: 100 }).blur();
cy.wait("@validate_link");
cy.wait(500);
cy.get(".frappe-control[data-fieldname=link] input").should("have.value", "");
cy.window()
.its("cur_dialog")
Expand Down Expand Up @@ -263,6 +268,7 @@ context("Control Link", () => {
cy.wait("@search_link");
cy.get("@input").type("Sonstiges", { delay: 100 });
cy.wait("@search_link");
cy.wait(500);
cy.get(".frappe-control[data-fieldname=link] ul").should("be.visible");
cy.get(".frappe-control[data-fieldname=link] input").type("{enter}", { delay: 100 });
cy.get(".frappe-control[data-fieldname=link] input").blur();
Expand All @@ -285,7 +291,7 @@ context("Control Link", () => {
});

cy.clear_cache();
cy.wait(500);
cy.wait(1000);

get_dialog_with_gender_link().as("dialog");
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
Expand All @@ -294,6 +300,7 @@ context("Control Link", () => {
cy.wait("@search_link");
cy.get("@input").type("Non-Conforming", { delay: 100 });
cy.wait("@search_link");
cy.wait(500);
cy.get(".frappe-control[data-fieldname=link] ul").should("be.visible");
cy.get(".frappe-control[data-fieldname=link] input").type("{enter}", { delay: 100 });
cy.get(".frappe-control[data-fieldname=link] input").blur();
Expand Down
6 changes: 5 additions & 1 deletion cypress/integration/file_uploader.js
@@ -1,7 +1,11 @@
context("FileUploader", () => {
before(() => {
cy.login();
});

beforeEach(() => {
cy.visit("/app");
cy.wait(2000); // workspace can load async and clear active dialog
});

function open_upload_dialog() {
Expand All @@ -10,7 +14,7 @@ context("FileUploader", () => {
.then((frappe) => {
new frappe.ui.FileUploader();
});
cy.wait(1000);
cy.wait(500);
}

it("upload dialog api works", () => {
Expand Down
41 changes: 0 additions & 41 deletions cypress/integration/permissions.js

This file was deleted.

5 changes: 1 addition & 4 deletions frappe/contacts/doctype/address/address.py
Expand Up @@ -174,15 +174,12 @@ def get_address_list(doctype, txt, filters, limit_start, limit_page_length=20, o
from frappe.www.list import get_list

user = frappe.session.user
ignore_permissions = True

if not filters:
filters = []
filters.append(("Address", "owner", "=", user))

return get_list(
doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions
)
return get_list(doctype, txt, filters, limit_start, limit_page_length)


def has_website_permission(doc, ptype, user, verbose=False):
Expand Down
15 changes: 0 additions & 15 deletions frappe/core/doctype/audit_trail/audit_trail.py
Expand Up @@ -11,21 +11,6 @@


class AuditTrail(Document):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from frappe.types import DF

doctype_name: DF.Link
document: DF.DynamicLink
end_date: DF.Date | None
start_date: DF.Date | None
# end: auto-generated types
pass

def validate(self):
self.validate_fields()
self.validate_document()
Expand Down
12 changes: 3 additions & 9 deletions frappe/core/doctype/data_import/data_import.js
Expand Up @@ -409,15 +409,9 @@ frappe.ui.form.on("Data Import", {

render_import_log(frm) {
frappe.call({
method: "frappe.client.get_list",
method: "frappe.core.doctype.data_import.data_import.get_import_logs",
args: {
doctype: "Data Import Log",
filters: {
data_import: frm.doc.name,
},
fields: ["success", "docname", "messages", "exception", "row_indexes"],
limit_page_length: 5000,
order_by: "log_index",
data_import: frm.doc.name,
},
callback: function (r) {
let logs = r.message;
Expand Down Expand Up @@ -509,7 +503,7 @@ frappe.ui.form.on("Data Import", {
show_import_log(frm) {
frm.toggle_display("import_log_section", false);

if (frm.import_in_progress) {
if (frm.is_new() || frm.import_in_progress) {
return;
}

Expand Down
22 changes: 20 additions & 2 deletions frappe/core/doctype/data_import/data_import.py
Expand Up @@ -64,7 +64,8 @@ def start_import(self):
from frappe.core.page.background_jobs.background_jobs import get_info
from frappe.utils.scheduler import is_scheduler_inactive

if is_scheduler_inactive() and not frappe.flags.in_test:
run_now = frappe.flags.in_test or frappe.conf.developer_mode
if is_scheduler_inactive() and not run_now:
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))

job_id = f"data_import::{self.name}"
Expand All @@ -77,7 +78,7 @@ def start_import(self):
event="data_import",
job_id=job_id,
data_import=self.name,
now=frappe.conf.developer_mode or frappe.flags.in_test,
now=run_now,
)
return True

Expand Down Expand Up @@ -189,6 +190,23 @@ def get_import_status(data_import_name):
return import_status


@frappe.whitelist()
def get_import_logs(data_import: str):
if not isinstance(data_import, str):
raise ValueError("data_import must be a string")

doc = frappe.get_doc("Data Import", data_import)
doc.check_permission("read")

return frappe.get_all(
"Data Import Log",
fields=["success", "docname", "messages", "exception", "row_indexes"],
filters={"data_import": data_import},
limit_page_length=5000,
order_by="log_index",
)


def import_file(doctype, file_path, import_type, submit_after_import=False, console=False):
"""
Import documents in from CSV or XLSX using data import.
Expand Down
7 changes: 4 additions & 3 deletions frappe/core/doctype/data_import_log/data_import_log.json
Expand Up @@ -58,9 +58,8 @@
}
],
"in_create": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-12-29 11:19:19.646076",
"modified": "2024-04-29 18:44:17.050909",
"modified_by": "Administrator",
"module": "Core",
"name": "Data Import Log",
Expand All @@ -79,6 +78,8 @@
"write": 1
}
],
"read_only": 1,
"sort_field": "modified",
"sort_order": "DESC"
"sort_order": "DESC",
"states": []
}
10 changes: 5 additions & 5 deletions frappe/core/doctype/doctype/doctype.py
Expand Up @@ -30,6 +30,7 @@
from frappe.model.meta import Meta
from frappe.modules import get_doc_path, make_boilerplate
from frappe.modules.import_file import get_file_path
from frappe.permissions import ALL_USER_ROLE, AUTOMATIC_ROLES, SYSTEM_USER_ROLE
from frappe.query_builder.functions import Concat
from frappe.utils import cint, is_a_property, random_string
from frappe.website.utils import clear_cache
Expand Down Expand Up @@ -1560,7 +1561,7 @@ def check_double(d):
)

def check_level_zero_is_set(d):
if cint(d.permlevel) > 0 and d.role != "All":
if cint(d.permlevel) > 0 and d.role not in (ALL_USER_ROLE, SYSTEM_USER_ROLE):
has_zero_perm = False
for p in permissions:
if p.role == d.role and (p.permlevel or 0) == 0 and p != d:
Expand Down Expand Up @@ -1619,11 +1620,11 @@ def validate_permission_for_all_role(d):
return

if doctype.custom:
if d.role == "All":
if d.role in AUTOMATIC_ROLES:
frappe.throw(
_(
"Row # {0}: Non administrator user can not set the role {1} to the custom doctype"
).format(d.idx, frappe.bold(_("All"))),
).format(d.idx, frappe.bold(_(d.role))),
title=_("Permissions Error"),
)

Expand Down Expand Up @@ -1673,8 +1674,7 @@ def make_module_and_roles(doc, perm_fieldname="permissions"):
m.custom = 1
m.insert()

default_roles = ["Administrator", "Guest", "All"]
roles = [p.role for p in doc.get("permissions") or []] + default_roles
roles = [p.role for p in doc.get("permissions") or []] + list(AUTOMATIC_ROLES)

for role in list(set(roles)):
if frappe.db.table_exists("Role", cached=False) and not frappe.db.exists("Role", role):
Expand Down
5 changes: 3 additions & 2 deletions frappe/core/doctype/navbar_settings/navbar_settings.js
Expand Up @@ -2,6 +2,7 @@
// For license information, please see license.txt

frappe.ui.form.on("Navbar Settings", {
// refresh: function(frm) {
// }
after_save: function (frm) {
frappe.ui.toolbar.clear_cache();
},
});
7 changes: 6 additions & 1 deletion frappe/core/doctype/role/role.js
Expand Up @@ -5,7 +5,12 @@ frappe.ui.form.on("Role", {
refresh: function (frm) {
if (frm.doc.name === "All") {
frm.dashboard.add_comment(
__("Role 'All' will be given to all System Users."),
__("Role 'All' will be given to all system + website users."),
"yellow"
);
} else if (frm.doc.name === "Desk User") {
frm.dashboard.add_comment(
__("Role 'Desk User' will be given to all system users."),
"yellow"
);
}
Expand Down
Expand Up @@ -4,6 +4,8 @@
import frappe
from frappe.core.doctype.report.report import is_prepared_report_disabled
from frappe.model.document import Document
from frappe.permissions import ALL_USER_ROLE
from frappe.utils import cint


class RolePermissionforPageandReport(Document):
Expand Down Expand Up @@ -79,11 +81,11 @@ def get_args(self, row=None):
return {check_for_field: name}

def get_roles(self):
roles = []
for data in self.roles:
if data.role != "All":
roles.append({"role": data.role, "parenttype": "Custom Role"})
return roles
return [
{"role": data.role, "parenttype": "Custom Role"}
for data in self.roles
if data.role != ALL_USER_ROLE
]

def update_status(self):
return frappe.render_template
7 changes: 3 additions & 4 deletions frappe/core/doctype/scheduled_job_type/scheduled_job_type.py
Expand Up @@ -91,7 +91,7 @@ def get_next_execution(self):
}

if not self.cron_format:
self.cron_format = CRON_MAP[self.frequency]
self.cron_format = CRON_MAP.get(self.frequency)

# If this is a cold start then last_execution will not be set.
# Creation is set as fallback because if very old fallback is set job might trigger
Expand Down Expand Up @@ -129,9 +129,8 @@ def log_status(self, status):
def update_scheduler_log(self, status):
if not self.create_log:
# self.get_next_execution will work properly iff self.last_execution is properly set
if self.frequency == "All" and status == "Start":
self.db_set("last_execution", now_datetime(), update_modified=False)
frappe.db.commit()
self.db_set("last_execution", now_datetime(), update_modified=False)
frappe.db.commit()
return
if not self.scheduler_log:
self.scheduler_log = frappe.get_doc(
Expand Down

0 comments on commit 0a2aaec

Please sign in to comment.